Class: Performer::ConditionVariable Private
- Inherits:
-
Object
- Object
- Performer::ConditionVariable
- Extended by:
- Forwardable
- Defined in:
- lib/performer/condition_variable.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A custom ConditionVariable.
It delegates to ConditionVariable for #wait, #signal and #broadcast, but also provides a reliable #wait_until.
Instance Method Summary collapse
-
#initialize ⇒ ConditionVariable
constructor
private
A new instance of ConditionVariable.
-
#wait_until(mutex, timeout = nil) { ... } ⇒ Object
private
Wait until a given condition is true, determined by calling the given block.
Constructor Details
#initialize ⇒ ConditionVariable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ConditionVariable.
14 15 16 |
# File 'lib/performer/condition_variable.rb', line 14 def initialize @condvar = ::ConditionVariable.new end |
Instance Method Details
#wait_until(mutex, timeout = nil) { ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method will honor the timeout, even in the case of spurious wakeups.
Wait until a given condition is true, determined by calling the given block.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/performer/condition_variable.rb', line 34 def wait_until(mutex, timeout = nil) unless block_given? raise ArgumentError, "no block given" end if timeout finished = Time.now + timeout until yield timeout = finished - Time.now break unless timeout > 0 wait(mutex, timeout) end else wait(mutex) until yield end return self end |