Class: MontorLock

Inherits:
Object
  • Object
show all
Defined in:
lib/farcall/monitor_lock.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeMontorLock

Returns a new instance of MontorLock.



6
7
8
9
# File 'lib/farcall/monitor_lock.rb', line 6

def initialize
  @condition = ConditionVariable.new
  @mutex = Mutex.new
end

Instance Method Details

#notifyObject



11
12
13
14
15
# File 'lib/farcall/monitor_lock.rb', line 11

def notify
  @mutex.synchronize {
    @condition.signal
  }
end

#waitObject



17
18
19
20
21
22
# File 'lib/farcall/monitor_lock.rb', line 17

def wait
  @mutex.synchronize {
    @condition.wait(@mutex)
    yield if block_given?
  }
end