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 void CPL_DLL *CPLCreateMutex( void );
00063 int CPL_DLL CPLCreateOrAcquireMutex( void **, double dfWaitInSeconds );
00064 int CPL_DLL CPLAcquireMutex( void *hMutex, double dfWaitInSeconds );
00065 void CPL_DLL CPLReleaseMutex( void *hMutex );
00066 void CPL_DLL CPLDestroyMutex( void *hMutex );
00067 void CPL_DLL CPLCleanupMasterMutex( void );
00068
00069 void CPL_DLL *CPLCreateCond( void );
00070 void CPL_DLL CPLCondWait( void *hCond, void* hMutex );
00071 void CPL_DLL CPLCondSignal( void *hCond );
00072 void CPL_DLL CPLCondBroadcast( void *hCond );
00073 void CPL_DLL CPLDestroyCond( void *hCond );
00074
00075 GIntBig CPL_DLL CPLGetPID( void );
00076 int CPL_DLL CPLCreateThread( CPLThreadFunc pfnMain, void *pArg );
00077 void CPL_DLL* CPLCreateJoinableThread( CPLThreadFunc pfnMain, void *pArg );
00078 void CPL_DLL CPLJoinThread(void* hJoinableThread);
00079 void CPL_DLL CPLSleep( double dfWaitInSeconds );
00080
00081 const char CPL_DLL *CPLGetThreadingModel( void );
00082
00083 int CPL_DLL CPLGetNumCPUs( void );
00084
00085 CPL_C_END
00086
00087 #ifdef __cplusplus
00088
00089
00090 #define CPLMutexHolderD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__);
00091
00092
00093
00094 #define CPLMutexHolderOptionalLockD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__);
00095
00096 class CPL_DLL CPLMutexHolder
00097 {
00098 private:
00099 void *hMutex;
00100 const char *pszFile;
00101 int nLine;
00102
00103 public:
00104
00105
00106 CPLMutexHolder( void **phMutex, double dfWaitInSeconds = 1000.0,
00107 const char *pszFile = __FILE__,
00108 int nLine = __LINE__ );
00109
00110
00111
00112 CPLMutexHolder( void* hMutex, double dfWaitInSeconds = 1000.0,
00113 const char *pszFile = __FILE__,
00114 int nLine = __LINE__ );
00115
00116 ~CPLMutexHolder();
00117 };
00118 #endif
00119
00120
00121
00122
00123
00124 #define CTLS_RLBUFFERINFO 1
00125 #define CTLS_WIN32_COND 2
00126 #define CTLS_CSVTABLEPTR 3
00127 #define CTLS_CSVDEFAULTFILENAME 4
00128 #define CTLS_ERRORCONTEXT 5
00129 #define CTLS_GDALDATASET_REC_PROTECT_MAP 6
00130 #define CTLS_PATHBUF 7
00131 #define CTLS_UNUSED3 8
00132 #define CTLS_UNUSED4 9
00133 #define CTLS_CPLSPRINTF 10
00134 #define CTLS_RESPONSIBLEPID 11
00135 #define CTLS_VERSIONINFO 12
00136 #define CTLS_VERSIONINFO_LICENCE 13
00137 #define CTLS_CONFIGOPTIONS 14
00138 #define CTLS_FINDFILE 15
00139
00140 #define CTLS_MAX 32
00141
00142 CPL_C_START
00143 void CPL_DLL * CPLGetTLS( int nIndex );
00144 void CPL_DLL CPLSetTLS( int nIndex, void *pData, int bFreeOnExit );
00145
00146
00147
00148 typedef void (*CPLTLSFreeFunc)( void* pData );
00149 void CPL_DLL CPLSetTLSWithFreeFunc( int nIndex, void *pData, CPLTLSFreeFunc pfnFree );
00150
00151 void CPL_DLL CPLCleanupTLS( void );
00152 CPL_C_END
00153
00154 #endif