class Semaphore
Public Class Methods
new(state_set=false)
click to toggle source
# File lib/farcall/monitor_lock.rb, line 29 def initialize state_set=false @monitor = MontorLock.new @state_set = state_set end
Public Instance Methods
clear()
click to toggle source
# File lib/farcall/monitor_lock.rb, line 71 def clear set false end
clear?()
click to toggle source
# File lib/farcall/monitor_lock.rb, line 38 def clear? !set? end
set(new_state=true)
click to toggle source
# File lib/farcall/monitor_lock.rb, line 64 def set new_state=true if @state_set != new_state @state_set = new_state @monitor.notify end end
set?()
click to toggle source
# File lib/farcall/monitor_lock.rb, line 34 def set? @state_set end
wait(state)
click to toggle source
# File lib/farcall/monitor_lock.rb, line 42 def wait state while @state_set != state do @monitor.wait end @state_set end
wait_change(&block)
click to toggle source
# File lib/farcall/monitor_lock.rb, line 57 def wait_change &block @monitor.wait { block.call(@state_set) if block } @state_set end
wait_clear()
click to toggle source
# File lib/farcall/monitor_lock.rb, line 53 def wait_clear wait false end
wait_set()
click to toggle source
# File lib/farcall/monitor_lock.rb, line 49 def wait_set wait true end