DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_mutex.h00001 /*****************************************************************************/ 00002 // Copyright 2006-2008 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/dng_sdk_1_2/dng_sdk/source/dng_mutex.h#1 $ */ 00010 /* $DateTime: 2008/03/09 14:29:54 $ */ 00011 /* $Change: 431850 $ */ 00012 /* $Author: tknoll $ */ 00013 00014 /******************************************************************************/ 00015 00016 #ifndef __dng_mutex__ 00017 #define __dng_mutex__ 00018 00019 /******************************************************************************/ 00020 00021 #include "dng_flags.h" 00022 00023 /******************************************************************************/ 00024 00025 #if qDNGThreadSafe 00026 00027 #include "dng_types.h" 00028 #include "dng_pthread.h" 00029 00030 #endif 00031 00032 /******************************************************************************/ 00033 00034 class dng_mutex 00035 { 00036 00037 public: 00038 00039 enum 00040 { 00041 kDNGMutexLevelLeaf = 0xffffffffu 00042 }; 00043 00044 dng_mutex (const char *mutexName, 00045 uint32 mutexLevel = kDNGMutexLevelLeaf); 00046 00047 virtual ~dng_mutex (); 00048 00049 void Lock (); 00050 00051 void Unlock (); 00052 00053 const char *MutexName () const; 00054 00055 protected: 00056 00057 #if qDNGThreadSafe 00058 00059 pthread_mutex_t fPthreadMutex; 00060 00061 const uint32 fMutexLevel; 00062 00063 uint32 fRecursiveLockCount; 00064 00065 dng_mutex *fPrevHeldMutex; 00066 00067 const char * const fMutexName; 00068 00069 friend class dng_condition; 00070 00071 #endif 00072 00073 private: 00074 00075 // Hidden copy constructor and assignment operator. 00076 00077 dng_mutex (const dng_mutex &mutex); 00078 00079 dng_mutex & operator= (const dng_mutex &mutex); 00080 00081 }; 00082 00083 /*****************************************************************************/ 00084 00085 class dng_lock_mutex 00086 { 00087 00088 private: 00089 00090 dng_mutex *fMutex; 00091 00092 public: 00093 00094 dng_lock_mutex (dng_mutex *mutex); 00095 00096 ~dng_lock_mutex (); 00097 00098 private: 00099 00100 // Hidden copy constructor and assignment operator. 00101 00102 dng_lock_mutex (const dng_lock_mutex &lock); 00103 00104 dng_lock_mutex & operator= (const dng_lock_mutex &lock); 00105 00106 }; 00107 00108 /*****************************************************************************/ 00109 00110 #if qDNGThreadSafe 00111 00112 /*****************************************************************************/ 00113 00114 class dng_condition 00115 { 00116 00117 public: 00118 00119 dng_condition (); 00120 00121 ~dng_condition (); 00122 00123 bool Wait (dng_mutex &mutex, double timeoutSecs = -1.0); 00124 00125 void Signal (); 00126 00127 void Broadcast (); 00128 00129 protected: 00130 00131 pthread_cond_t fPthreadCondition; 00132 00133 private: 00134 00135 // Hidden copy constructor and assignment operator. 00136 00137 dng_condition (const dng_condition &condition); 00138 00139 dng_condition & operator= (const dng_condition &condition); 00140 00141 }; 00142 00143 /*****************************************************************************/ 00144 00145 #endif // qDNGThreadSafe 00146 00147 /*****************************************************************************/ 00148 00149 #endif 00150 00151 /*****************************************************************************/ | |||
