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

C:/temp/src/j2k/nto/Mutex.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__PThread_Mutex_HPP__
00002 #define __J2K__PThread_Mutex_HPP__
00003 
00004 #include <j2k/Fred/Standard.hpp>
00005 // #include <j2k/Fred/Error/JErrorController.hpp>
00006 
00007 #define MC_OnError( x, y, z )  if( x != 0 ){ printf( "An error occured [%d]\n", x ); } 
00008 
00009 #include <errno.h>
00010 #include <pthread.h>
00011 #include <time.h>
00012 
00013 // Uses:
00014 // pthread_mutex_t
00015 // pthread_mutex_attr_t
00016 
00017 class PThread_Mutex {
00018 public:
00019 
00020 /******************************************************
00021  **  Description of pthread_mutex_attr_t arguments.  **
00022  **                                                  **
00023  **  Attribute         Default Value                 **
00024  **  =========         =============                 **
00025  **  detachstate       PTHREAD_CREATE_JOINABLE       **
00026  **  schedpolicy       PTHREAD_INHERIT_SCHED         **
00027  **  schedparam        Inherited from parent thread  **
00028  **  contentionscope   PTHREAD_SCOPE_SYSTEM          **
00029  **  stacksize         4096                          **
00030  **  stackaddr         NULL                          **
00031  ******************************************************/
00032 
00033   // Default Constructor
00034   PThread_Mutex();
00035 
00036   // Destructor
00037   virtual ~PThread_Mutex();
00038 
00039   // Lock the mutex
00040   void lock();
00041 
00042   // Unlock the mutex
00043   void unlock();
00044 
00045   // Try to lock a mutex
00046   inline void tryLock();
00047 
00048   // Get the maximum priority (ceiling value) for the mutex
00049   inline int getPriorityCeiling();
00050 
00051   // Set the maximum priority (ceiling value) for the mutex
00052   inline int setPriorityCeiling( int new_ceiling );
00053 
00054   // Get the mutex attribute type
00055   inline int getType();
00056 
00057   // Get the mutex attribute protocol
00058   inline int getProtocol();
00059 
00060   inline void P() { lock(); }
00061   inline void V() { unlock(); }
00062 
00063 private:
00064   int   mutex_type;
00065   int   protocol;
00066   int   prioceiling;
00067   int   state;
00068   pid_t owner;
00069 
00070   pthread_mutexattr_t attr;
00071   pthread_mutex_t     mutex;
00072 
00073 
00074 // Not implemented or needed.
00075 private:
00076   // Copy constructor
00077   inline PThread_Mutex( const PThread_Mutex& src );
00078 
00079   // Assign operator
00080   inline const PThread_Mutex& operator=( const PThread_Mutex& src );
00081 };
00082 
00083 typedef PThread_Mutex  Mutex;
00084 
00085 
00086 #include <j2k/nto/Mutex.inl>
00087 
00088 #endif

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