Class: IOPromise::Faraday::FaradayPromise

Inherits:
Base
  • Object
show all
Defined in:
lib/iopromise/faraday/promise.rb

Class Method Summary collapse

Instance Method Summary collapse

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_managerObject



9
10
11
# File 'lib/iopromise/faraday/promise.rb', line 9

def self.parallel_manager
  ContinuableHydra.for_current_thread
end

Instance Method Details

#execute_poolObject



36
37
38
# File 'lib/iopromise/faraday/promise.rb', line 36

def execute_pool
  FaradayExecutorPool.for(Thread.current)
end

#waitObject



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