Class: Hx::Interop::Channel::Blocker

Inherits:
Object
  • Object
show all
Defined in:
lib/interop/channel.rb

Overview

:nodoc:

Direct Known Subclasses

Get, Put

Instance Method Summary collapse

Constructor Details

#initializeBlocker

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

#resolveObject



19
20
21
22
23
# File 'lib/interop/channel.rb', line 19

def resolve
  @queue << nil
  @queue.close
  @value
end

#waitObject



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