Class: Hx::Interop::Channel::Blocker
- Inherits:
-
Object
- Object
- Hx::Interop::Channel::Blocker
- Defined in:
- lib/interop/channel.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize ⇒ Blocker
constructor
A new instance of Blocker.
- #resolve ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize ⇒ Blocker
Returns a new instance of Blocker.
14 15 16 17 |
# File 'lib/interop/channel.rb', line 14 def initialize @queue = Queue.new @mutex = Mutex.new end |
Instance Method Details
#resolve ⇒ Object
19 20 21 22 23 |
# File 'lib/interop/channel.rb', line 19 def resolve @queue << nil @queue.close @value end |
#wait ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/interop/channel.rb', line 25 def wait @mutex.synchronize do next unless @queue @queue.shift @queue = nil end @value end |