|
The Pedigree Project 0.1
|
#include <ConditionVariable.h>
Collaboration diagram for ConditionVariable:Public Types | |
| enum | Error { NoError , TimedOut , Interrupted , TerminationDeferred , MutexNotLocked } |
Public Member Functions | |
| MUST_USE_RESULT bool | wait (Mutex &mutex, Time::Timestamp &timeout, Error &error, WaitQueue::StackDiscardCleanup onStackDiscard=nullptr, void *stackDiscardContext=nullptr) |
| MUST_USE_RESULT bool | wait (Mutex &mutex, Error &error, WaitQueue::StackDiscardCleanup onStackDiscard=nullptr, void *stackDiscardContext=nullptr) |
| void | waitForCompletion (Mutex &mutex) |
| void | signal () |
| void | broadcast () |
Static Public Member Functions | |
| static bool | mutexAcquired (Error error) |
Private Attributes | |
| WaitQueue | m_Waiters |
| void * | m_Private |
| Private data. | |
ConditionVariable provides an abstraction over condition variables.
Definition at line 35 of file ConditionVariable.h.
| enum ConditionVariable::Error |
Definition at line 37 of file ConditionVariable.h.
| ConditionVariable::ConditionVariable | ( | ) |
Definition at line 58 of file ConditionVariable.cc.
| ConditionVariable::~ConditionVariable | ( | ) |
Definition at line 60 of file ConditionVariable.cc.
| void ConditionVariable::broadcast | ( | ) |
Wake up all threads currently waiting.
Definition at line 162 of file ConditionVariable.cc.
Referenced by MqueueNetlinkSocket::lastDescriptorClosed(), UnlikelyLock::leave(), EventFd::readValue(), UnlikelyLock::release(), and EventFd::writeValue().
Here is the caller graph for this function:
|
inlinestatic |
Whether wait() returned with ownership of the supplied mutex.
Definition at line 40 of file ConditionVariable.h.
Referenced by MemoryPool::allocateDoer(), Buffer< T, allowShortOperation >::canRead(), Buffer< T, allowShortOperation >::canWrite(), Buffer< T, allowShortOperation >::read(), EventFd::readValue(), Pipe::waitForReader(), and EventFd::writeValue().
Here is the caller graph for this function:| void ConditionVariable::signal | ( | ) |
Wake up at least one thread that is currently waiting.
Definition at line 158 of file ConditionVariable.cc.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), ProducerConsumer::destroy(), and MemoryPool::free().
Here is the caller graph for this function:| bool ConditionVariable::wait | ( | Mutex & | mutex, |
| Error & | error, | ||
| WaitQueue::StackDiscardCleanup | onStackDiscard = nullptr, |
||
| void * | stackDiscardContext = nullptr |
||
| ) |
Wait for a signal on the condition variable with no timeout.
Definition at line 62 of file ConditionVariable.cc.
References wait().
| bool ConditionVariable::wait | ( | Mutex & | mutex, |
| Time::Timestamp & | timeout, | ||
| Error & | error, | ||
| WaitQueue::StackDiscardCleanup | onStackDiscard = nullptr, |
||
| void * | stackDiscardContext = nullptr |
||
| ) |
Wait for a signal on the condition variable with a specific timeout.
The timeout specifies a relative deadline in nanoseconds. Zero requests an immediate timeout; use Time::Infinity or the overload without a timeout parameter to wait indefinitely. If the operation times out, the value is set to zero. If it succeeds first, the value is the remaining timeout.
The mutex is reacquired for every returning outcome. Forced thread termination returns TerminationDeferred with the mutex held so the caller can retire stack-owned state while unwinding toward a thread boundary.
| [in] | mutex | an acquired mutex protecting the resource. |
| [in,out] | timeout | a relative timeout in nanoseconds, zero for an immediate deadline, or Time::Infinity for no deadline. |
Definition at line 69 of file ConditionVariable.cc.
References ProcessorBase::information().
Referenced by MemoryPool::allocateDoer(), EventFd::readValue(), wait(), Pipe::waitForReader(), and EventFd::writeValue().
Here is the caller graph for this function:| void ConditionVariable::waitForCompletion | ( | Mutex & | mutex | ) |
Wait for a lifetime predicate which must be rechecked with mutex held.
Signal and terminal events are delivered but cannot abandon the wait or mutex reacquisition. A delivered signal remains recorded on the current Thread so an outer syscall boundary can still report interruption after the protected lifetime state has drained.
Definition at line 144 of file ConditionVariable.cc.
References WaitQueue::Guard::waitAndUnlockForCompletion().
Referenced by UnlikelyLock::acquire(), and UnlikelyLock::enter().
Here is the caller graph for this function:
|
private |
Private data.
Definition at line 94 of file ConditionVariable.h.
|
private |
Definition at line 90 of file ConditionVariable.h.