Class: Concurrent::Channel::UnbufferedChannel
- Inherits:
-
Object
- Object
- Concurrent::Channel::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.
10 11 12 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 10 def initialize @probe_set = WaitableList.new end |
Instance Method Details
#pop ⇒ Object
23 24 25 26 27 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 23 def pop probe = Channel::Probe.new select(probe) probe.value end |
#probe_set_size ⇒ Object
14 15 16 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 14 def probe_set_size @probe_set.size end |
#push(value) ⇒ Object
18 19 20 21 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 18 def push(value) until @probe_set.take.try_set([value, self]) end end |
#remove_probe(probe) ⇒ Object
33 34 35 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 33 def remove_probe(probe) @probe_set.delete(probe) end |
#select(probe) ⇒ Object
29 30 31 |
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 29 def select(probe) @probe_set.put(probe) end |