class Concurrent::Edge::BlockedPromise
@abstract @!visibility private
Public Class Methods
new(*args, &block)
click to toggle source
Calls superclass method
Concurrent::Edge::AbstractPromise.new
# File lib/concurrent/edge/future.rb, line 1012 def self.new(*args, &block) promise = super(*args, &block) promise.blocked_by.each { |f| f.add_callback :callback_notify_blocked, promise } promise end
new(future, blocked_by_futures, countdown)
click to toggle source
Calls superclass method
Concurrent::Edge::AbstractPromise.new
# File lib/concurrent/edge/future.rb, line 1018 def initialize(future, blocked_by_futures, countdown) super(future) initialize_blocked_by(blocked_by_futures) @Countdown = AtomicFixnum.new countdown end
Public Instance Methods
blocked_by()
click to toggle source
!visibility private for inspection only
# File lib/concurrent/edge/future.rb, line 1043 def blocked_by @BlockedBy end
inspect()
click to toggle source
# File lib/concurrent/edge/future.rb, line 1047 def inspect "#{to_s[0..-2]} blocked_by:[#{ blocked_by.map(&:to_s).join(', ')}]>" end
on_done(future)
click to toggle source
@api private
# File lib/concurrent/edge/future.rb, line 1025 def on_done(future) countdown = process_on_done(future) completable = completable?(countdown, future) if completable on_completable(future) # futures could be deleted from blocked_by one by one here, but that would be too expensive, # it's done once when all are done to free the reference clear_blocked_by! end end
touch()
click to toggle source
# File lib/concurrent/edge/future.rb, line 1037 def touch blocked_by.each(&:touch) end
Private Instance Methods
clear_blocked_by!()
click to toggle source
# File lib/concurrent/edge/future.rb, line 1057 def clear_blocked_by! # not synchronized because we do not care when this change propagates @BlockedBy = [] nil end
completable?(countdown, future)
click to toggle source
@return [true,false] if completable
# File lib/concurrent/edge/future.rb, line 1064 def completable?(countdown, future) countdown.zero? end
initialize_blocked_by(blocked_by_futures)
click to toggle source
# File lib/concurrent/edge/future.rb, line 1053 def initialize_blocked_by(blocked_by_futures) @BlockedBy = [blocked_by_futures].flatten end
on_completable(done_future)
click to toggle source
# File lib/concurrent/edge/future.rb, line 1072 def on_completable(done_future) raise NotImplementedError end
process_on_done(future)
click to toggle source
# File lib/concurrent/edge/future.rb, line 1068 def process_on_done(future) @Countdown.decrement end