00001 #ifndef __J2K__PThread_Mutex_INL__
00002 #define __J2K__PThread_Mutex_INL__
00003
00004
00005
00006
00007
00008
00009 inline PThread_Mutex::PThread_Mutex( const PThread_Mutex& src )
00010 {
00011 memcpy( &attr, &src.attr, sizeof( pthread_mutexattr_t ) );
00012 memcpy( &mutex, &src.mutex, sizeof( pthread_mutex_t ) );
00013 state = 0;
00014 }
00015
00016
00017 inline const PThread_Mutex& PThread_Mutex::operator=( const PThread_Mutex& src )
00018 {
00019 memcpy( &attr, &src.attr, sizeof( pthread_mutexattr_t ) );
00020 memcpy( &mutex, &src.mutex, sizeof( pthread_mutex_t ) );
00021 state = 0;
00022
00023 return *this;
00024 }
00025
00026
00027 inline void PThread_Mutex::tryLock()
00028 {
00029 int err = pthread_mutex_trylock( &mutex );
00030 MC_OnError( err, Error, "An error happened while trying to lock a mutex." )
00031 }
00032
00033
00034 inline int PThread_Mutex::getPriorityCeiling()
00035 {
00036 int ceiling = 0;
00037 int err = pthread_mutex_getprioceiling( &mutex, &ceiling );
00038 MC_OnError( err, Error, "An error happened while retrieving the priority ceiling of a mutex." )
00039
00040 return ceiling;
00041 }
00042
00043
00044 inline int PThread_Mutex::setPriorityCeiling( int new_ceiling )
00045 {
00046 int old_ceiling = 0;
00047
00048 int err = pthread_mutex_setprioceiling( &mutex, new_ceiling, &old_ceiling );
00049 MC_OnError( err, Error, "An error happened while setting the priority ceiling of a mutex." )
00050
00051 return old_ceiling;
00052 }
00053
00054
00055 inline int PThread_Mutex::getType()
00056 {
00057 int mtype = 0;
00058
00059 int err = pthread_mutexattr_gettype( &attr, &mtype );
00060 MC_OnError( err, Error, "An error happened while getting the mutex type." )
00061
00062 return mtype;
00063 }
00064
00065
00066 inline int PThread_Mutex::getProtocol()
00067 {
00068 int err = pthread_mutexattr_getprotocol( &attr, &protocol );
00069 MC_OnError( err, Error, "while getting the mutex attribute protocol.")
00070
00071 return protocol;
00072 }
00073
00074 #endif
00075