In Files

  • monitor.rb

MonitorMixin::ConditionVariable

FIXME: This isn’t documented in Nutshell.

Since MonitorMixin#new_cond returns a ConditionVariable, and the example above calls while_wait and signal, this class should be documented.

Public Class Methods

new(monitor) click to toggle source
 
               # File monitor.rb, line 132
def initialize(monitor)
  @monitor = monitor
  @cond = ::ConditionVariable.new
end
            

Public Instance Methods

broadcast() click to toggle source
 
               # File monitor.rb, line 121
def broadcast
  @monitor.__send__(:mon_check_owner)
  @cond.broadcast
end
            
count_waiters() click to toggle source
 
               # File monitor.rb, line 126
def count_waiters
  raise NotImplementedError
end
            
signal() click to toggle source
 
               # File monitor.rb, line 116
def signal
  @monitor.__send__(:mon_check_owner)
  @cond.signal
end
            
wait(timeout = nil) click to toggle source
 
               # File monitor.rb, line 90
def wait(timeout = nil)
  if timeout
    raise NotImplementedError, "timeout is not implemented yet"
  end
  @monitor.__send__(:mon_check_owner)
  count = @monitor.__send__(:mon_exit_for_cond)
  begin
    @cond.wait(@monitor.instance_variable_get("@mon_mutex"))
    return true
  ensure
    @monitor.__send__(:mon_enter_for_cond, count)
  end
end
            
wait_until() click to toggle source
 
               # File monitor.rb, line 110
def wait_until
  until yield
    wait
  end
end
            
wait_while() click to toggle source
 
               # File monitor.rb, line 104
def wait_while
  while yield
    wait
  end
end