00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _CPL_MULTIPROC_H_INCLUDED_
00032 #define _CPL_MULTIPROC_H_INCLUDED_
00033
00034 #include "cpl_port.h"
00035
00036
00037
00038
00039
00040
00041
00042
00043 #if defined(WIN32) && !defined(CPL_MULTIPROC_STUB)
00044 # define CPL_MULTIPROC_WIN32
00045
00046
00047 # undef CPL_MULTIPROC_PTHREAD
00048 #endif
00049
00050 #if !defined(CPL_MULTIPROC_WIN32) && !defined(CPL_MULTIPROC_PTHREAD) \
00051 && !defined(CPL_MULTIPROC_STUB) && !defined(CPL_MULTIPROC_NONE)
00052 # define CPL_MULTIPROC_STUB
00053 #endif
00054
00055 CPL_C_START
00056
00057 typedef void (*CPLThreadFunc)(void *);
00058
00059 void CPL_DLL *CPLLockFile( const char *pszPath, double dfWaitInSeconds );
00060 void CPL_DLL CPLUnlockFile( void *hLock );
00061
00062 #ifdef DEBUG
00063 typedef struct _CPLMutex CPLMutex;
00064 typedef struct _CPLCond CPLCond;
00065 typedef struct _CPLJoinableThread CPLJoinableThread;
00066 #else
00067 #define CPLMutex void
00068 #define CPLCond void
00069 #define CPLJoinableThread void
00070 #endif
00071
00072
00073 #define CPL_MUTEX_RECURSIVE 0
00074 #define CPL_MUTEX_ADAPTIVE 1
00075
00076 CPLMutex CPL_DLL *CPLCreateMutex( void );
00077 CPLMutex CPL_DLL *CPLCreateMutexEx( int nOptions );
00078 int CPL_DLL CPLCreateOrAcquireMutex( CPLMutex **, double dfWaitInSeconds );
00079 int CPL_DLL CPLCreateOrAcquireMutexEx( CPLMutex **, double dfWaitInSeconds, int nOptions );
00080 int CPL_DLL CPLAcquireMutex( CPLMutex *hMutex, double dfWaitInSeconds );
00081 void CPL_DLL CPLReleaseMutex( CPLMutex *hMutex );
00082 void CPL_DLL CPLDestroyMutex( CPLMutex *hMutex );
00083 void CPL_DLL CPLCleanupMasterMutex( void );
00084
00085 CPLCond CPL_DLL *CPLCreateCond( void );
00086 void CPL_DLL CPLCondWait( CPLCond *hCond, CPLMutex* hMutex );
00087 void CPL_DLL CPLCondSignal( CPLCond *hCond );
00088 void CPL_DLL CPLCondBroadcast( CPLCond *hCond );
00089 void CPL_DLL CPLDestroyCond( CPLCond *hCond );
00090
00091 GIntBig CPL_DLL CPLGetPID( void );
00092 int CPL_DLL CPLCreateThread( CPLThreadFunc pfnMain, void *pArg );
00093 CPLJoinableThread CPL_DLL* CPLCreateJoinableThread( CPLThreadFunc pfnMain, void *pArg );
00094 void CPL_DLL CPLJoinThread(CPLJoinableThread* hJoinableThread);
00095 void CPL_DLL CPLSleep( double dfWaitInSeconds );
00096
00097 const char CPL_DLL *CPLGetThreadingModel( void );
00098
00099 int CPL_DLL CPLGetNumCPUs( void );
00100
00101
00102 typedef struct _CPLLock CPLLock;
00103
00104
00105
00106
00107 typedef enum
00108 {
00109 LOCK_RECURSIVE_MUTEX,
00110 LOCK_ADAPTIVE_MUTEX,
00111 LOCK_SPIN
00112 } CPLLockType;
00113
00114 CPLLock CPL_DLL *CPLCreateLock( CPLLockType eType );
00115 int CPL_DLL CPLCreateOrAcquireLock( CPLLock**, CPLLockType eType );
00116 int CPL_DLL CPLAcquireLock( CPLLock* );
00117 void CPL_DLL CPLReleaseLock( CPLLock* );
00118 void CPL_DLL CPLDestroyLock( CPLLock* );
00119 void CPL_DLL CPLLockSetDebugPerf( CPLLock*, int bEnableIn );
00120
00121
00122 CPL_C_END
00123
00124 #ifdef __cplusplus
00125
00126
00127 #define CPLMutexHolderD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__);
00128
00129
00130
00131 #define CPLMutexHolderExD(x, nOptions) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__,nOptions);
00132
00133
00134
00135 #define CPLMutexHolderOptionalLockD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__);
00136
00137 class CPL_DLL CPLMutexHolder
00138 {
00139 private:
00140 CPLMutex *hMutex;
00141 const char *pszFile;
00142 int nLine;
00143
00144 public:
00145
00146
00147 CPLMutexHolder( CPLMutex **phMutex, double dfWaitInSeconds = 1000.0,
00148 const char *pszFile = __FILE__,
00149 int nLine = __LINE__,
00150 int nOptions = CPL_MUTEX_RECURSIVE);
00151
00152
00153
00154 CPLMutexHolder( CPLMutex* hMutex, double dfWaitInSeconds = 1000.0,
00155 const char *pszFile = __FILE__,
00156 int nLine = __LINE__ );
00157
00158 ~CPLMutexHolder();
00159 };
00160
00161
00162 #define CPLLockHolderD(x, eType) CPLLockHolder oHolder(x,eType,__FILE__,__LINE__);
00163
00164
00165
00166 #define CPLLockHolderOptionalLockD(x) CPLLockHolder oHolder(x,__FILE__,__LINE__);
00167
00168 class CPL_DLL CPLLockHolder
00169 {
00170 private:
00171 CPLLock *hLock;
00172 const char *pszFile;
00173 int nLine;
00174
00175 public:
00176
00177
00178 CPLLockHolder( CPLLock **phSpin, CPLLockType eType,
00179 const char *pszFile = __FILE__,
00180 int nLine = __LINE__);
00181
00182
00183
00184 CPLLockHolder( CPLLock* hSpin,
00185 const char *pszFile = __FILE__,
00186 int nLine = __LINE__ );
00187
00188 ~CPLLockHolder();
00189 };
00190
00191
00192 #endif
00193
00194
00195
00196
00197
00198 #define CTLS_RLBUFFERINFO 1
00199 #define CTLS_WIN32_COND 2
00200 #define CTLS_CSVTABLEPTR 3
00201 #define CTLS_CSVDEFAULTFILENAME 4
00202 #define CTLS_ERRORCONTEXT 5
00203 #define CTLS_GDALDATASET_REC_PROTECT_MAP 6
00204 #define CTLS_PATHBUF 7
00205 #define CTLS_UNUSED3 8
00206 #define CTLS_UNUSED4 9
00207 #define CTLS_CPLSPRINTF 10
00208 #define CTLS_RESPONSIBLEPID 11
00209 #define CTLS_VERSIONINFO 12
00210 #define CTLS_VERSIONINFO_LICENCE 13
00211 #define CTLS_CONFIGOPTIONS 14
00212 #define CTLS_FINDFILE 15
00213
00214 #define CTLS_MAX 32
00215
00216 CPL_C_START
00217 void CPL_DLL * CPLGetTLS( int nIndex );
00218 void CPL_DLL CPLSetTLS( int nIndex, void *pData, int bFreeOnExit );
00219
00220
00221
00222 typedef void (*CPLTLSFreeFunc)( void* pData );
00223 void CPL_DLL CPLSetTLSWithFreeFunc( int nIndex, void *pData, CPLTLSFreeFunc pfnFree );
00224
00225 void CPL_DLL CPLCleanupTLS( void );
00226 CPL_C_END
00227
00228 #endif