@!visibility private
# File lib/concurrent/edge/future.rb, line 1169 def initialize(blocked_by_future, levels, default_executor) raise ArgumentError, 'levels has to be higher than 0' if levels < 1 super Future.new(self, default_executor), blocked_by_future, 1 + levels end
!visibility private
# File lib/concurrent/edge/future.rb, line 1138 def blocked_by @BlockedBy.each.to_a end
# File lib/concurrent/edge/future.rb, line 1182 def clear_blocked_by! @BlockedBy.clear nil end
# File lib/concurrent/edge/future.rb, line 1187 def completable?(countdown) !@Future.internal_state.completed? && super(countdown) end
# File lib/concurrent/edge/future.rb, line 1174 def initialize_blocked_by(blocked_by_future) @BlockedBy = LockFreeStack.new.push(blocked_by_future) end
# File lib/concurrent/edge/future.rb, line 1178 def on_completable(done_future) complete_with done_future.internal_state end
# File lib/concurrent/edge/future.rb, line 1144 def process_on_done(future) countdown = super(future) if countdown.nonzero? internal_state = future.internal_state unless internal_state.success? complete_with internal_state return countdown end value = internal_state.value case value when Future @BlockedBy.push value value.add_callback :pr_callback_notify_blocked, self @Countdown.value when Event evaluate_to(lambda { raise TypeError, 'cannot flatten to Event' }) else evaluate_to(lambda { raise TypeError, "returned value #{value.inspect} is not a Future" }) end end countdown end