Class: Concurrent::UnbufferedChannel
- Inherits:
-
Object
- Object
- Concurrent::UnbufferedChannel
- Defined in:
- lib/concurrent/channel/unbuffered_channel.rb
Instance Method Summary collapse
-
#initialize ⇒ UnbufferedChannel
constructor
A new instance of UnbufferedChannel.
- #pop ⇒ Object
- #probe_set_size ⇒ Object
- #push(value) ⇒ Object
- #remove_probe(probe) ⇒ Object
- #select(probe) ⇒ Object
Constructor Details
#initialize ⇒ UnbufferedChannel
Returns a new instance of UnbufferedChannel.
6 7 8 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 6 def initialize @probe_set = WaitableList.new end |
Instance Method Details
#pop ⇒ Object
19 20 21 22 23 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 19 def pop probe = Channel::Probe.new select(probe) probe.value end |
#probe_set_size ⇒ Object
10 11 12 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 10 def probe_set_size @probe_set.size end |
#push(value) ⇒ Object
14 15 16 17 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 14 def push(value) until @probe_set.take.set_unless_assigned(value, self) end end |
#remove_probe(probe) ⇒ Object
29 30 31 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 29 def remove_probe(probe) @probe_set.delete(probe) end |
#select(probe) ⇒ Object
25 26 27 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 25 def select(probe) @probe_set.put(probe) end |