The Pedigree Project  0.1
Public Types | Public Member Functions | Private Attributes | List of all members
ConditionVariable Class Reference

#include <ConditionVariable.h>

+ Collaboration diagram for ConditionVariable:

Public Types

enum  Error {
  NoError, TimedOut, ThreadTerminating, MutexNotLocked,
  MutexNotAcquired
}
 
typedef Result< bool, Error > WaitResult
 

Public Member Functions

WaitResult wait (Mutex &mutex, Time::Timestamp &timeout)
 
WaitResult wait (Mutex &mutex)
 
void signal ()
 
void broadcast ()
 

Private Attributes

Spinlock m_Lock
 Lock around m_Waiters.
 
List< Thread * > m_Waiters
 Threads waiting for a signal.
 

Detailed Description

ConditionVariable provides an abstraction over condition variables.

Definition at line 36 of file ConditionVariable.h.

Member Function Documentation

void ConditionVariable::broadcast ( )

Wake up all threads currently waiting.

Definition at line 174 of file ConditionVariable.cc.

Referenced by RequestQueue::halt().

+ 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.

References Spinlock::acquire(), Thread::getLock(), Spinlock::release(), and Thread::setStatus().

Referenced by RequestQueue::addRequest().

+ Here is the caller graph for this function:

ConditionVariable::WaitResult ConditionVariable::wait ( Mutex mutex,
Time::Timestamp &  timeout 
)

Wait for a signal on the condition variable with a specific timeout.

If the given timeout is non-zero, it specifies a timeout for the wait operation. If the operation times out, the value will be set to zero. If the operation succeeds before the timeout expires, the value will be the amount of time remaining in the timeout.

Parameters
[in]mutexan acquired mutex protecting the resource.
[in,out]timeouta timeout in nanoseconds to wait (or zero for none).
Todo:
this is actually buggy as it won't respect the timeout

Definition at line 49 of file ConditionVariable.cc.

References Semaphore::acquire(), Thread::Continue, Thread::getUnwindState(), Semaphore::getValue(), Processor::information(), Semaphore::release(), Thread::setDebugState(), Thread::setInterrupted(), WARNING, and Thread::wasInterrupted().

Referenced by ProducerConsumer::consumerThread(), PerProcessorScheduler::processorAddThread(), and RequestQueue::work().

+ Here is the caller graph for this function:

ConditionVariable::WaitResult ConditionVariable::wait ( Mutex mutex)

Wait for a signal on the condition variable with no timeout.

Definition at line 42 of file ConditionVariable.cc.


The documentation for this class was generated from the following files: