Class: Faraday::Adapter::EMSynchrony::ParallelManager
- Inherits:
-
Object
- Object
- Faraday::Adapter::EMSynchrony::ParallelManager
- Defined in:
- lib/faraday/adapter/em_synchrony/parallel_manager.rb
Overview
A parallel manager for EMSynchrony.
Instance Method Summary collapse
-
#add(request, method, *args, &block) ⇒ Object
Add requests to queue.
-
#run ⇒ Object
Run all requests on queue with ‘EM::Synchrony::Multi`, wrapping it in a reactor and fiber if needed.
Instance Method Details
#add(request, method, *args, &block) ⇒ Object
Add requests to queue.
13 14 15 16 17 18 19 20 |
# File 'lib/faraday/adapter/em_synchrony/parallel_manager.rb', line 13 def add(request, method, *args, &block) queue << { request: request, method: method, args: args, block: block } end |
#run ⇒ Object
Run all requests on queue with ‘EM::Synchrony::Multi`, wrapping it in a reactor and fiber if needed.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/faraday/adapter/em_synchrony/parallel_manager.rb', line 24 def run result = nil if !EM.reactor_running? EM.run do Fiber.new do result = perform EM.stop end.resume end else result = perform end result end |