Panda3D
 All Classes Functions Variables Enumerations
conditionVarPosixImpl.I
00001 // Filename: conditionVarPosixImpl.I
00002 // Created by:  drose (10Feb06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: ConditionVarPosixImpl::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE ConditionVarPosixImpl::
00022 ConditionVarPosixImpl(MutexPosixImpl &mutex) :
00023   _mutex(mutex)
00024 {
00025   TAU_PROFILE("ConditionVarPosixImpl::ConditionVarPosixImpl()", " ", TAU_USER);
00026   int result = pthread_cond_init(&_cvar, NULL);
00027   nassertv(result == 0);
00028 }
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //     Function: ConditionVarPosixImpl::Destructor
00032 //       Access: Public
00033 //  Description:
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE ConditionVarPosixImpl::
00036 ~ConditionVarPosixImpl() {
00037   TAU_PROFILE("ConditionVarPosixImpl::~ConditionVarPosixImpl()", " ", TAU_USER);
00038   int result = pthread_cond_destroy(&_cvar);
00039   nassertv(result == 0);
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: ConditionVarPosixImpl::wait
00044 //       Access: Public
00045 //  Description: 
00046 ////////////////////////////////////////////////////////////////////
00047 INLINE void ConditionVarPosixImpl::
00048 wait() {
00049   TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER);
00050   int result = pthread_cond_wait(&_cvar, &_mutex._lock);
00051 #ifndef NDEBUG
00052   if (result != 0) {
00053     pipeline_cat.error()
00054       << "Unexpected error " << result << " from pthread_cond_wait()\n";
00055   }
00056 #endif
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: ConditionVarPosixImpl::notify
00061 //       Access: Public
00062 //  Description: 
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void ConditionVarPosixImpl::
00065 notify() {
00066   TAU_PROFILE("ConditionVarPosixImpl::notify()", " ", TAU_USER);
00067   int result = pthread_cond_signal(&_cvar);
00068   nassertv(result == 0);
00069 }
00070 
00071 ////////////////////////////////////////////////////////////////////
00072 //     Function: ConditionVarPosixImpl::notify_all
00073 //       Access: Public
00074 //  Description: 
00075 ////////////////////////////////////////////////////////////////////
00076 INLINE void ConditionVarPosixImpl::
00077 notify_all() {
00078   TAU_PROFILE("ConditionVarPosixImpl::notify()", " ", TAU_USER);
00079   int result = pthread_cond_broadcast(&_cvar);
00080   nassertv(result == 0);
00081 }
 All Classes Functions Variables Enumerations