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/workarea/stern/camera_raw/dng_sdk/source/dng_mutex.h#9 $ */ 00010 /* $DateTime: 2009/02/09 22:30:36 $ */ 00011 /* $Change: 539360 $ */ 00012 /* $Author: stern $ */ 00013 00014 /******************************************************************************/ 00015 00016 #ifndef __dng_mutex__ 00017 #define __dng_mutex__ 00018 00019 /******************************************************************************/ 00020 00021 #include "dng_flags.h" 00022 00023 /******************************************************************************/ 00024 00025 #include "dng_types.h" 00026 00027 #if qDNGThreadSafe 00028 00029 #include "dng_pthread.h" 00030 00031 #endif 00032 00033 /******************************************************************************/ 00034 00035 class dng_mutex 00036 { 00037 00038 public: 00039 00040 enum 00041 { 00042 kDNGMutexLevelLeaf = 0xffffffffu 00043 }; 00044 00045 dng_mutex (const char *mutexName, 00046 uint32 mutexLevel = kDNGMutexLevelLeaf); 00047 00048 virtual ~dng_mutex (); 00049 00050 void Lock (); 00051 00052 void Unlock (); 00053 00054 const char *MutexName () const; 00055 00056 protected: 00057 00058 #if qDNGThreadSafe 00059 00060 pthread_mutex_t fPthreadMutex; 00061 00062 const uint32 fMutexLevel; 00063 00064 uint32 fRecursiveLockCount; 00065 00066 dng_mutex *fPrevHeldMutex; 00067 00068 const char * const fMutexName; 00069 00070 friend class dng_condition; 00071 00072 #endif 00073 00074 private: 00075 00076 // Hidden copy constructor and assignment operator. 00077 00078 dng_mutex (const dng_mutex &mutex); 00079 00080 dng_mutex & operator= (const dng_mutex &mutex); 00081 00082 }; 00083 00084 /*****************************************************************************/ 00085 00086 class dng_lock_mutex 00087 { 00088 00089 private: 00090 00091 dng_mutex *fMutex; 00092 00093 public: 00094 00095 dng_lock_mutex (dng_mutex *mutex); 00096 00097 ~dng_lock_mutex (); 00098 00099 private: 00100 00101 // Hidden copy constructor and assignment operator. 00102 00103 dng_lock_mutex (const dng_lock_mutex &lock); 00104 00105 dng_lock_mutex & operator= (const dng_lock_mutex &lock); 00106 00107 }; 00108 00109 /*****************************************************************************/ 00110 00111 class dng_unlock_mutex 00112 { 00113 00114 private: 00115 00116 dng_mutex *fMutex; 00117 00118 public: 00119 00120 dng_unlock_mutex (dng_mutex *mutex); 00121 00122 ~dng_unlock_mutex (); 00123 00124 private: 00125 00126 // Hidden copy constructor and assignment operator. 00127 00128 dng_unlock_mutex (const dng_unlock_mutex &unlock); 00129 00130 dng_unlock_mutex & operator= (const dng_unlock_mutex &unlock); 00131 00132 }; 00133 00134 /*****************************************************************************/ 00135 00136 #if qDNGThreadSafe 00137 00138 /*****************************************************************************/ 00139 00140 class dng_condition 00141 { 00142 00143 public: 00144 00145 dng_condition (); 00146 00147 ~dng_condition (); 00148 00149 bool Wait (dng_mutex &mutex, double timeoutSecs = -1.0); 00150 00151 void Signal (); 00152 00153 void Broadcast (); 00154 00155 protected: 00156 00157 pthread_cond_t fPthreadCondition; 00158 00159 private: 00160 00161 // Hidden copy constructor and assignment operator. 00162 00163 dng_condition (const dng_condition &condition); 00164 00165 dng_condition & operator= (const dng_condition &condition); 00166 00167 }; 00168 00169 /*****************************************************************************/ 00170 00171 #endif // qDNGThreadSafe 00172 00173 /*****************************************************************************/ 00174 00175 #endif 00176 00177 /*****************************************************************************/ |