nidas v1.2.3
|
A C++ wrapper for a POSIX mutex. More...
#include <ThreadSupport.h>
Public Member Functions | |
Mutex (int type=PTHREAD_MUTEX_DEFAULT) throw () | |
Construct a POSIX mutex of the given type. | |
Mutex (const MutexAttributes &attr) | |
Construct a POSIX mutex with the given attributes. | |
Mutex (const Mutex &x) throw () | |
Copy constructor. | |
~Mutex () | |
Destruct a Mutex. | |
void | lock () |
Lock the Mutex. | |
void | unlock () |
Unlock the Mutex. | |
pthread_mutex_t * | ptr () |
Get the pointer to the pthread_mutex_t. | |
Private Member Functions | |
Mutex & | operator= (const Mutex &) |
No assignment allowed. | |
Private Attributes | |
pthread_mutex_t | _p_mutex |
MutexAttributes | _attrs |
A C++ wrapper for a POSIX mutex.
|
explicit |
Construct a POSIX mutex of the given type.
type | One of PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_DEFAULT (default). See man page for pthread_mutex_init, and pthread_mutexattr_settype. The following error conditions could occur in this constructor, but they are not thrown as exceptions. EAGAIN: system lacked resources ENOMEM: system lacked memory An exception will likely occur later when an lock attempt is made on this Mutex. |
Mutex::Mutex | ( | const MutexAttributes & | attr | ) |
Construct a POSIX mutex with the given attributes.
This constructor can throw an exception in the following circumstances: EAGAIN: system lacked resources ENOMEM: system lacked memory EINVAL: invalid attributes
Exception |
References _attrs, _p_mutex, and nidas::util::MutexAttributes::ptr().
Mutex::Mutex | ( | const Mutex & | x | ) | ||
throw | ( | ) |
Copy constructor.
Creates a new, unlocked mutex with the same attributes as x. The error handling is the same as with the default constructor.
Mutex::~Mutex | ( | ) |
|
inline |
Lock the Mutex.
An exception will be thrown with error condition EDEADLK if this is a PTHREAD_MUTEX_ERRORCHECK type Mutex, and the current thread has already locked it. An exception for error EINVAL will be thrown if the Mutex was created with the protocol attribute having the value PTHREAD_PRIO_PROTECT and the calling thread’s priority is higher than the mutex’s current priority ceiling.
Exception |
References _p_mutex.
Referenced by nidas::core::SensorHandler::add(), nidas::util::McSocketListener::add(), nidas::util::McSocketListener::add(), nidas::core::SensorHandler::add(), nidas::core::MultipleUDPSockets::addClient(), nidas::core::DerivedDataReader::addClient(), nidas::core::SensorHandler::addSensor(), nidas::core::Project::addSite(), nidas::util::Autolock::Autolock(), nidas::core::StatusHandler::characters(), nidas::core::MultipleUDPSockets::close(), nidas::core::DSMEngine::closeOutputs(), nidas::dynld::raf::CVIProcessor::connectSource(), nidas::dynld::StatisticsProcessor::connectSource(), nidas::core::GetClocks::execute(), nidas::core::GetStatus::execute(), nidas::core::Project::findDSM(), nidas::core::Project::findSensor(), nidas::core::FsMount::finished(), nidas::dynld::SampleProcessor::flush(), nidas::dynld::StatisticsProcessor::flush(), nidas::core::MultipleUDPSockets::handleChangedSockets(), nidas::core::SensorHandler::handlePollingChange(), nidas::core::Sample::holdReference(), nidas::core::SamplePipeline::interrupt(), nidas::core::SamplePipeline::join(), nidas::util::Cond::lock(), nidas::core::SampleClientList::lock(), nidas::core::DerivedDataReader::notifyClients(), nidas::dynld::RawSampleService::printStatus(), nidas::util::Thread::pRun(), nidas::core::SensorHandler::remove(), nidas::core::SensorHandler::remove(), nidas::core::SampleSourceSupport::removeAllSampleClients(), nidas::core::DerivedDataReader::removeClient(), nidas::core::Looper::removeClient(), nidas::core::Looper::run(), nidas::core::SensorHandler::run(), nidas::util::McSocketListener::run(), nidas::core::SensorHandler::scheduleAdd(), nidas::core::SensorHandler::scheduleClose(), nidas::core::SensorHandler::scheduleClose(), nidas::core::SensorHandler::scheduleReopen(), nidas::dynld::StatisticsProcessor::selectRequestedSampleTags(), nidas::core::SensorHandler::sensorIsOpen(), nidas::util::Synchronized::Synchronized(), nidas::util::Thread::thr_cleanup_delete(), nidas::core::SampleArchiver::~SampleArchiver(), nidas::core::SamplePipeline::~SamplePipeline(), nidas::core::SamplePools::~SamplePools(), nidas::dynld::SampleProcessor::~SampleProcessor(), nidas::dynld::StatisticsProcessor::~StatisticsProcessor(), and nidas::dynld::raf::SyncRecordGenerator::~SyncRecordGenerator().
pthread_mutex_t * Mutex::ptr | ( | ) |
Get the pointer to the pthread_mutex_t.
References _p_mutex.
Referenced by nidas::util::Cond::wait().
|
inline |
Unlock the Mutex.
An exception will be thrown for error condition EPERM if this is an PTHREAD_MUTEX_ERRORCHECK Mutex and the current thread does not hold a lock.
Exception |
References _p_mutex.
Referenced by nidas::core::SensorHandler::add(), nidas::util::McSocketListener::add(), nidas::util::McSocketListener::add(), nidas::core::SensorHandler::add(), nidas::core::MultipleUDPSockets::addClient(), nidas::core::DerivedDataReader::addClient(), nidas::core::SensorHandler::addSensor(), nidas::core::Project::addSite(), nidas::core::StatusHandler::characters(), nidas::core::MultipleUDPSockets::close(), nidas::core::DSMEngine::closeOutputs(), nidas::dynld::raf::CVIProcessor::connectSource(), nidas::dynld::StatisticsProcessor::connectSource(), nidas::core::GetClocks::execute(), nidas::core::GetStatus::execute(), nidas::core::Project::findDSM(), nidas::core::Project::findSensor(), nidas::core::FsMount::finished(), nidas::dynld::SampleProcessor::flush(), nidas::dynld::StatisticsProcessor::flush(), nidas::core::MultipleUDPSockets::handleChangedSockets(), nidas::core::SensorHandler::handlePollingChange(), nidas::core::Sample::holdReference(), nidas::core::SamplePipeline::interrupt(), nidas::core::SamplePipeline::join(), nidas::core::DerivedDataReader::notifyClients(), nidas::dynld::RawSampleService::printStatus(), nidas::util::Thread::pRun(), nidas::core::SensorHandler::remove(), nidas::core::SensorHandler::remove(), nidas::core::SampleSourceSupport::removeAllSampleClients(), nidas::core::DerivedDataReader::removeClient(), nidas::core::Looper::removeClient(), nidas::core::Looper::run(), nidas::core::SensorHandler::run(), nidas::util::McSocketListener::run(), nidas::core::SensorHandler::scheduleAdd(), nidas::core::SensorHandler::scheduleClose(), nidas::core::SensorHandler::scheduleClose(), nidas::core::SensorHandler::scheduleReopen(), nidas::dynld::StatisticsProcessor::selectRequestedSampleTags(), nidas::core::SensorHandler::sensorIsOpen(), nidas::util::Cond::unlock(), nidas::core::SampleClientList::unlock(), nidas::util::Autolock::~Autolock(), nidas::core::SampleArchiver::~SampleArchiver(), nidas::core::SamplePipeline::~SamplePipeline(), nidas::core::SamplePools::~SamplePools(), nidas::dynld::SampleProcessor::~SampleProcessor(), nidas::dynld::StatisticsProcessor::~StatisticsProcessor(), nidas::util::Synchronized::~Synchronized(), and nidas::dynld::raf::SyncRecordGenerator::~SyncRecordGenerator().
|
private |
Referenced by Mutex().
|
private |