class BitGirder::Concurrent::Rendezvous
Attributes
remain[R]
Public Class Methods
new( &blk )
click to toggle source
Calls superclass method
BitGirder::Core::BitGirderStructure::new
# File lib/bitgirder/concurrent.rb, line 86 def initialize( &blk ) super( {} ) @on_join = blk # could be nil @remain = 0 end
run() { |run| ... }
click to toggle source
# File lib/bitgirder/concurrent.rb, line 159 def self.run run = Run.new yield( run ) blk = run.instance_variable_get( :@on_join ) raise "Need a complete block" unless blk r = Rendezvous.new( &blk ) run.instance_variable_get( :@fires ).each { |f| r.fire; f.call( r ) } r.close end
Public Instance Methods
arrive()
click to toggle source
# File lib/bitgirder/concurrent.rb, line 113 def arrive if @remain == 0 raise UnderflowError else check_complete if @remain -= 1 end end
close()
click to toggle source
# File lib/bitgirder/concurrent.rb, line 128 def close if closed? raise ClosedError else @closed = true check_complete end end
closed?()
click to toggle source
# File lib/bitgirder/concurrent.rb, line 123 def closed? @closed end
fire()
click to toggle source
# File lib/bitgirder/concurrent.rb, line 95 def fire raise ClosedError if closed? @remain += 1 end
open?()
click to toggle source
# File lib/bitgirder/concurrent.rb, line 139 def open? ! closed? end
Private Instance Methods
check_complete()
click to toggle source
# File lib/bitgirder/concurrent.rb, line 102 def check_complete if @remain == 0 && closed? if @on_join @on_join.call end end end