|
nidas v1.2.3
|
A wrapper class for a Posix condition variable. More...
#include <ThreadSupport.h>
Public Member Functions | |
| Cond () throw () | |
| Construct a POSIX condition variable, with default attributes. | |
| Cond (const Cond &x) throw () | |
| Copy constructor. | |
| ~Cond () | |
| Destruct a Cond. | |
| void | lock () |
| Lock the mutex associated with the condition variable. | |
| void | unlock () |
| Unlock the mutex associated with the condition variable. | |
| void | signal () |
| Unblock at least one thread waiting on the condition variable. | |
| void | broadcast () |
| Restart all threads waiting on the condition variable. | |
| void | wait () |
| Wait on the condition variable. | |
Private Member Functions | |
| Cond & | operator= (const Cond &) |
| No assignment allowed. | |
Private Attributes | |
| pthread_cond_t | _p_cond |
| Mutex | _mutex |
A wrapper class for a Posix condition variable.
| Cond::Cond | ( | ) | ||||
| throw | ( | ) | ||||
Construct a POSIX condition variable, with default attributes.
See man page for pthread_cond_init.
References _p_cond.
| Cond::Cond | ( | const Cond & | x | ) | ||
| throw | ( | ) | ||||
Copy constructor.
Creates new unlocked condition variable and mutex.
| Cond::~Cond | ( | ) |
|
inline |
Restart all threads waiting on the condition variable.
References _p_cond.
Referenced by PacketReader::loop(), nidas::core::SampleBuffer::run(), nidas::core::SampleSorter::run(), nidas::util::Multisync::sync(), and nidas::util::Multisync::sync().
|
inline |
Lock the mutex associated with the condition variable.
Here is an example (lifted from the pthread_cond_init man page): of two threads sharing variables x and y. One thread waits for a signal that x is greater than y:
Another thread manipulates x and y and signals when x > y:
| Exception |
References _mutex, and nidas::util::Mutex::lock().
Referenced by nidas::core::SampleOutputRequestThread::addConnectRequest(), nidas::core::SampleOutputRequestThread::addDeleteRequest(), nidas::util::Autolock::Autolock(), nidas::core::SampleOutputRequestThread::clear(), nidas::dynld::raf::SyncRecordReader::endOfStream(), nidas::core::SampleSorter::flush(), nidas::core::SampleBuffer::heapDecrement(), nidas::core::SampleSorter::heapDecrement(), nidas::core::SampleBuffer::interrupt(), nidas::core::SampleOutputRequestThread::interrupt(), nidas::core::SampleSorter::interrupt(), nidas::core::SensorOpener::interrupt(), PacketReader::loop(), nidas::dynld::raf::SyncRecordReader::nextSample(), nidas::core::SensorOpener::openSensor(), nidas::core::SensorOpener::reopenSensor(), WriterThread::run(), nidas::core::SampleBuffer::run(), nidas::core::SampleOutputRequestThread::run(), nidas::core::SampleSorter::run(), nidas::core::SensorOpener::run(), nidas::util::Synchronized::Synchronized(), PacketReader::~PacketReader(), and nidas::dynld::raf::SyncRecordReader::~SyncRecordReader().
|
inline |
Unblock at least one thread waiting on the condition variable.
| Exception |
References _p_cond.
Referenced by nidas::core::SampleOutputRequestThread::addConnectRequest(), nidas::core::SampleOutputRequestThread::addDeleteRequest(), nidas::dynld::raf::SyncRecordReader::endOfStream(), nidas::core::SampleSorter::flush(), nidas::core::SampleBuffer::heapDecrement(), nidas::core::SampleSorter::heapDecrement(), nidas::core::SampleBuffer::interrupt(), nidas::core::SampleOutputRequestThread::interrupt(), nidas::core::SampleSorter::interrupt(), nidas::core::SensorOpener::interrupt(), nidas::dynld::raf::SyncRecordReader::nextSample(), nidas::core::SensorOpener::openSensor(), nidas::core::SensorOpener::reopenSensor(), and nidas::core::SampleSorter::run().
|
inline |
Unlock the mutex associated with the condition variable.
| Exception |
References _mutex, and nidas::util::Mutex::unlock().
Referenced by nidas::core::SampleOutputRequestThread::addConnectRequest(), nidas::core::SampleOutputRequestThread::addDeleteRequest(), nidas::core::SampleOutputRequestThread::clear(), nidas::dynld::raf::SyncRecordReader::endOfStream(), nidas::core::SampleSorter::flush(), nidas::core::SampleBuffer::heapDecrement(), nidas::core::SampleSorter::heapDecrement(), nidas::core::SampleBuffer::interrupt(), nidas::core::SampleOutputRequestThread::interrupt(), nidas::core::SampleSorter::interrupt(), nidas::core::SensorOpener::interrupt(), PacketReader::loop(), nidas::dynld::raf::SyncRecordReader::nextSample(), nidas::core::SensorOpener::openSensor(), nidas::core::SensorOpener::reopenSensor(), WriterThread::run(), nidas::core::SampleBuffer::run(), nidas::core::SampleOutputRequestThread::run(), nidas::core::SampleSorter::run(), nidas::core::SensorOpener::run(), nidas::util::Autolock::~Autolock(), PacketReader::~PacketReader(), nidas::util::Synchronized::~Synchronized(), and nidas::dynld::raf::SyncRecordReader::~SyncRecordReader().
| void Cond::wait | ( | ) |
Wait on the condition variable.
| Exception |
References _mutex, _p_cond, and nidas::util::Mutex::ptr().
Referenced by nidas::core::SampleSorter::flush(), nidas::dynld::raf::SyncRecordReader::nextSample(), WriterThread::run(), nidas::core::SampleBuffer::run(), nidas::core::SampleOutputRequestThread::run(), nidas::core::SampleSorter::run(), nidas::core::SensorOpener::run(), nidas::util::Multisync::sync(), and nidas::util::Multisync::sync().
|
private |
Referenced by broadcast(), Cond(), signal(), wait(), and ~Cond().