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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus