Class: Issuesrc::SequentialEventLoop
- Defined in:
- lib/issuesrc/event_loop.rb
Instance Method Summary collapse
Methods inherited from EventLoop
#initialize, #wait_for_pending
Constructor Details
This class inherits a constructor from Issuesrc::EventLoop
Instance Method Details
#async_http_request(method, url, opts, &callback) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/issuesrc/event_loop.rb', line 69 def async_http_request(method, url, opts, &callback) @waiting += 1 if @busy @pending << [method, url, opts, callback] return end @busy = true @http_channel.push([method, url, opts, lambda do |req| if !callback.nil? callback.call req end @busy = false if @pending.length > 0 method, url, opts, callback = @pending[0] @pending = @pending[1..-1] @waiting -= 1 async_http_request(method, url, opts, &callback) end end]) end |