Class: IOPromise::Faraday::FaradayPromise
- Inherits:
-
Base
- Object
- Base
- IOPromise::Faraday::FaradayPromise
- Defined in:
- lib/iopromise/faraday/promise.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute_pool ⇒ Object
-
#initialize(response = nil) ⇒ FaradayPromise
constructor
A new instance of FaradayPromise.
- #wait ⇒ Object
Constructor Details
#initialize(response = nil) ⇒ FaradayPromise
Returns a new instance of FaradayPromise.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/iopromise/faraday/promise.rb', line 13 def initialize(response = nil) super() @response = response @started = false unless @response.nil? @response.on_complete do |response_env| fulfill(@response) end end ::IOPromise::ExecutorContext.current.register(self) unless @response.nil? end |
Class Method Details
.parallel_manager ⇒ Object
9 10 11 |
# File 'lib/iopromise/faraday/promise.rb', line 9 def self.parallel_manager ContinuableHydra.for_current_thread end |
Instance Method Details
#execute_pool ⇒ Object
36 37 38 |
# File 'lib/iopromise/faraday/promise.rb', line 36 def execute_pool FaradayExecutorPool.for(Thread.current) end |
#wait ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/iopromise/faraday/promise.rb', line 28 def wait if @response.nil? super else ::IOPromise::ExecutorContext.current.wait_for_all_data(end_when_complete: self) end end |