Class: BitGirder::Concurrent::Rendezvous
Defined Under Namespace
Classes: ClosedError, RendezvousStateError, Run, UnderflowError
Constant Summary
BitGirder::Core::BitGirderMethods::PARAM_TYPE_ARG, BitGirder::Core::BitGirderMethods::PARAM_TYPE_ENVVAR, BitGirder::Core::BitGirderMethods::PARAM_TYPE_KEY
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
argv_to_argh, check_fail_prefix, class_name_to_sym, code, compares_to, console, ext_to_class_name, ext_to_sym, has_env, has_key, has_keys, nonnegative, not_nil, positive, raisef, set_from_key, set_var, split_argv, sym_to_cli_switch, sym_to_ext_id, to_bool, unpack_argv_array, unpack_argv_hash, warn
#==, included
Constructor Details
Returns a new instance of Rendezvous.
86
87
88
89
90
91
92
|
# File 'lib/bitgirder/concurrent.rb', line 86
def initialize( &blk )
super( {} )
@on_join = blk @remain = 0
end
|
Instance Attribute Details
#remain ⇒ Object
Returns the value of attribute remain.
84
85
86
|
# File 'lib/bitgirder/concurrent.rb', line 84
def remain
@remain
end
|
Class Method Details
.run {|run| ... } ⇒ Object
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# 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
|
Instance Method Details
#arrive ⇒ Object
113
114
115
116
117
118
119
120
|
# File 'lib/bitgirder/concurrent.rb', line 113
def arrive
if @remain == 0
raise UnderflowError
else
check_complete if @remain -= 1
end
end
|
#close ⇒ Object
128
129
130
131
132
133
134
135
136
|
# File 'lib/bitgirder/concurrent.rb', line 128
def close
if closed?
raise ClosedError
else
@closed = true
check_complete
end
end
|
#closed? ⇒ Boolean
123
124
125
|
# File 'lib/bitgirder/concurrent.rb', line 123
def closed?
@closed
end
|
#fire ⇒ Object
95
96
97
98
99
|
# File 'lib/bitgirder/concurrent.rb', line 95
def fire
raise ClosedError if closed?
@remain += 1
end
|
#open? ⇒ Boolean
139
140
141
|
# File 'lib/bitgirder/concurrent.rb', line 139
def open?
! closed?
end
|