Class: Curl::Multi

Inherits:
Object
  • Object
show all
Defined in:
lib/http/compat/curb.rb

Instance Method Summary collapse

Constructor Details

#initializeMulti

Returns a new instance of Multi.



67
68
69
70
# File 'lib/http/compat/curb.rb', line 67

def initialize
  @clients = []
  @done = false
end

Instance Method Details

#add(client) ⇒ Object



72
73
74
# File 'lib/http/compat/curb.rb', line 72

def add(client)
  @clients << client
end

#performObject



77
78
79
80
81
82
83
84
85
# File 'lib/http/compat/curb.rb', line 77

def perform
  return if @done

  @clients.map do |client|
    Thread.new { client.perform }
  end.each(&:join)

  @done = true
end