class
Sync::ConditionVariable
- Sync::ConditionVariable
- Reference
- Object
Overview
Suspend a fiber until notified.
A ConditionVariable
can be associated to any Lockable
.
While one Lockable
can be associated to multiple ConditionVariable
, only
one ConditionVariable
can be associated to a single Lockable
(one-to-many relation).
Defined in:
condition_variable.crConstructors
Instance Method Summary
-
#broadcast : Nil
Wakes up all waiting fibers at once.
-
#signal : Nil
Wakes up one waiting fiber.
-
#wait : Nil
Blocks the calling fiber until the condition variable is signaled.
Constructor Detail
Instance Method Detail
Wakes up all waiting fibers at once.
You can wake a single waiting fiber with #signal
.
Wakes up one waiting fiber.
For RWLock
and Shared(T)
all readers can acquire, thus multiple
readers might be woken at once, but only one writer can acquire, thus only
one reader will be woken at a time.
You can wake all waiting fibers with #broadcast
.
Blocks the calling fiber until the condition variable is signaled.
The lock must be held upon calling. Releases lock before waiting, so any other fiber can acquire the lock while the calling fiber is waiting. The lock is re-acquired before returning.
A RWLock
and Shared(T)
can be held in either read or write mode, the
lock will be reacquired in the same mode (read or write) before returning.
The calling fiber will be woken by #signal
or #broadcast
.