class Concurrent::Edge::BlockedPromise

@abstract @!visibility private

Public Class Methods

new(future, blocked_by_futures, countdown) click to toggle source
Calls superclass method Concurrent::Edge::AbstractPromise.new
# File lib/concurrent/edge/future.rb, line 990
def initialize(future, blocked_by_futures, countdown)
  initialize_blocked_by(blocked_by_futures)
  @Countdown = AtomicFixnum.new countdown

  super(future)
  @BlockedBy.each { |f| f.add_callback :pr_callback_notify_blocked, self }
end

Public Instance Methods

blocked_by() click to toggle source

!visibility private for inspection only

# File lib/concurrent/edge/future.rb, line 1017
def blocked_by
  @BlockedBy
end
inspect() click to toggle source
# File lib/concurrent/edge/future.rb, line 1021
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 999
def on_done(future)
  countdown   = process_on_done(future)
  completable = completable?(countdown)

  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 1011
def touch
  blocked_by.each(&:touch)
end

Private Instance Methods

clear_blocked_by!() click to toggle source
# File lib/concurrent/edge/future.rb, line 1031
def clear_blocked_by!
  # not synchronized because we do not care when this change propagates
  @BlockedBy = []
  nil
end
completable?(countdown) click to toggle source

@return [true,false] if completable

# File lib/concurrent/edge/future.rb, line 1038
def completable?(countdown)
  countdown.zero?
end
initialize_blocked_by(blocked_by_futures) click to toggle source
# File lib/concurrent/edge/future.rb, line 1027
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 1046
def on_completable(done_future)
  raise NotImplementedError
end
process_on_done(future) click to toggle source
# File lib/concurrent/edge/future.rb, line 1042
def process_on_done(future)
  @Countdown.decrement
end