Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Deprecated/old_18mar_diff/nto/Mutex.inl

Go to the documentation of this file.
00001 #ifndef __J2K__PThread_Mutex_INL__
00002 #define __J2K__PThread_Mutex_INL__
00003 
00004 // Uses:
00005 // pthread_mutex_t
00006 // pthread_mutex_attr_t
00007 
00008   // Copy Constructor
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   // Assign Operator
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   // Try to lock a mutex
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   // Get the maximum priority (ceiling value) for the mutex
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   // Set the maximum priority (ceiling value) for the mutex  
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   // Get the mutex attribute type
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   // Get the mutex attribute protocol
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 

Generated on Sun Oct 14 18:46:23 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001