Om
1.0.0
A universal framework for multimedia simulation
|
A class that represents a thread-to-thread condition signaling event. More...
#include <omSignal.h>
Public Member Functions | |
Signal () | |
Create a new signal object. More... | |
Signal (const Signal &signal) | |
Create a copy of a signal object. More... | |
~Signal () | |
Destroy a signal object. More... | |
Signal & | operator= (const Signal &signal) |
Assign one signal to another. More... | |
Bool | signal () |
Send a signal to all listening threads. More... | |
Bool | signalOne () |
Send a signal to just one of the listening threads. More... | |
Bool | wait () const |
Wait until the signal is given by another thread. More... | |
Bool | wait (const time::Time &maxWaitTime) const |
Wait until the signal is given by another thread or a time period elapses. More... | |
Bool | lock () |
Lock the mutex associated with this signal. More... | |
Bool | unlock () |
Unlock this mutex associated with this signal. More... | |
A class that represents a thread-to-thread condition signaling event.
This class allows a thread to wait for a condition to be met. This will halt the execution of that thread until another thread signals that the condition is met. At that point the waiting thread wakes up and begins execution again. A typical application of this class would be in produce-consumer systems where one thread is waiting for data from another thread.
om::threads::Signal::Signal | ( | ) |
Create a new signal object.
om::threads::Signal::Signal | ( | const Signal & | signal | ) |
Create a copy of a signal object.
This has the effect of linking the two signal objects - whenever one is signaled, all listeners for the other receive the signal.
om::threads::Signal::~Signal | ( | ) |
Destroy a signal object.
This has the effect of signaling all listening threads that the signal has been sent. This is done in order to prevent deadlocks.
Assign one signal to another.
This has the effect of linking the two signal objects - whenever one is signaled, all listeners for the other receive the signal.
Bool om::threads::Signal::signal | ( | ) |
Send a signal to all listening threads.
Bool om::threads::Signal::signalOne | ( | ) |
Send a signal to just one of the listening threads.
Bool om::threads::Signal::wait | ( | ) | const |
Wait until the signal is given by another thread.
This method blocks the calling thread until another thread calls the signal() method on this object.
Bool om::threads::Signal::wait | ( | const time::Time & | maxWaitTime | ) | const |
Wait until the signal is given by another thread or a time period elapses.
This method blocks the calling thread until another thread calls the signal() method on this object, or the specified timeout period elapses.
The return value is TRUE if the thread was signaled, or FALSE if the timeout expired.
Bool om::threads::Signal::lock | ( | ) |
Lock the mutex associated with this signal.
Bool om::threads::Signal::unlock | ( | ) |
Unlock this mutex associated with this signal.