class Concurrent::Promises::FlatFuturePromise
Public Class Methods
new(delayed, blockers_count, levels, default_executor)
click to toggle source
Calls superclass method
Concurrent::Promises::AbstractFlatPromise::new
# File lib/concurrent-ruby/concurrent/promises.rb, line 1866 def initialize(delayed, blockers_count, levels, default_executor) raise ArgumentError, 'levels has to be higher than 0' if levels < 1 # flat promise may result to a future having delayed futures, therefore we have to have empty stack # to be able to add new delayed futures super delayed || LockFreeStack.new, 1 + levels, Future.new(self, default_executor) end
Private Instance Methods
process_on_blocker_resolution(future, index)
click to toggle source
Calls superclass method
Concurrent::Promises::BlockedPromise#process_on_blocker_resolution
# File lib/concurrent-ruby/concurrent/promises.rb, line 1873 def process_on_blocker_resolution(future, index) countdown = super(future, index) if countdown.nonzero? internal_state = future.internal_state unless internal_state.fulfilled? resolve_with internal_state return countdown end value = internal_state.value case value when AbstractEventFuture add_delayed_of value value.add_callback_notify_blocked self, nil countdown else evaluate_to(lambda { raise TypeError, "returned value #{value.inspect} is not a Future" }) end end countdown end