// PThreadConditionLocker.cxx #include "dataset_util/PThreadConditionLocker.h" #include //********************************************************************** // Methods. //********************************************************************** // Constructor from reference. PThreadConditionLocker::PThreadConditionLocker(PThreadCondition& mtx) : m_pmtx(&mtx) { if ( m_pmtx->is_locked() ) { assert( m_pmtx->lock_owner() != pthread_self() ); } int lstat = mtx.lock(); assert( lstat == 0 ); } //********************************************************************** // Constructor from pointer. PThreadConditionLocker::PThreadConditionLocker(PThreadCondition* pmtx) : m_pmtx(pmtx) { if ( m_pmtx != 0 ) { if ( m_pmtx->is_locked() ) { assert( m_pmtx->lock_owner() != pthread_self() ); } int lstat = m_pmtx->lock(); assert( lstat == 0 ); } } //********************************************************************** // Destructor. PThreadConditionLocker::~PThreadConditionLocker() { if ( m_pmtx!=0 ) { int ustat = m_pmtx->unlock(); assert( ustat == 0 ); m_pmtx->broadcast(); } } //**********************************************************************