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 #ifndef _CPL_MULTIPROC_H_INCLUDED_
00031 #define _CPL_MULTIPROC_H_INCLUDED_
00032
00033 #include "cpl_port.h"
00034
00035
00036
00037
00038
00039
00040
00041
00042 #if defined(WIN32) && !defined(CPL_MULTIPROC_STUB)
00043 # define CPL_MULTIPROC_WIN32
00044
00045
00046 # undef CPL_MULTIPROC_PTHREAD
00047 #endif
00048
00049 #if !defined(CPL_MULTIPROC_WIN32) && !defined(CPL_MULTIPROC_PTHREAD) \
00050 && !defined(CPL_MULTIPROC_STUB) && !defined(CPL_MULTIPROC_NONE)
00051 # define CPL_MULTIPROC_STUB
00052 #endif
00053
00054 CPL_C_START
00055
00056 typedef void (*CPLThreadFunc)(void *);
00057
00058 void CPL_DLL *CPLLockFile( const char *pszPath, double dfWaitInSeconds );
00059 void CPL_DLL CPLUnlockFile( void *hLock );
00060
00061 void CPL_DLL *CPLCreateMutex();
00062 int CPL_DLL CPLCreateOrAcquireMutex( void **, double dfWaitInSeconds );
00063 int CPL_DLL CPLAcquireMutex( void *hMutex, double dfWaitInSeconds );
00064 void CPL_DLL CPLReleaseMutex( void *hMutex );
00065 void CPL_DLL CPLDestroyMutex( void *hMutex );
00066
00067 void CPL_DLL *CPLCreateCond();
00068 void CPL_DLL CPLCondWait( void *hCond, void* hMutex );
00069 void CPL_DLL CPLCondSignal( void *hCond );
00070 void CPL_DLL CPLCondBroadcast( void *hCond );
00071 void CPL_DLL CPLDestroyCond( void *hCond );
00072
00073 GIntBig CPL_DLL CPLGetPID();
00074 int CPL_DLL CPLCreateThread( CPLThreadFunc pfnMain, void *pArg );
00075 void CPL_DLL* CPLCreateJoinableThread( CPLThreadFunc pfnMain, void *pArg );
00076 void CPL_DLL CPLJoinThread(void* hJoinableThread);
00077 void CPL_DLL CPLSleep( double dfWaitInSeconds );
00078
00079 const char CPL_DLL *CPLGetThreadingModel();
00080
00081 CPL_C_END
00082
00083 #ifdef __cplusplus
00084
00085 #define CPLMutexHolderD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__);
00086
00087 class CPL_DLL CPLMutexHolder
00088 {
00089 private:
00090 void *hMutex;
00091 const char *pszFile;
00092 int nLine;
00093
00094 public:
00095
00096 CPLMutexHolder( void **phMutex, double dfWaitInSeconds = 1000.0,
00097 const char *pszFile = __FILE__,
00098 int nLine = __LINE__ );
00099 ~CPLMutexHolder();
00100 };
00101 #endif
00102
00103
00104
00105
00106
00107 #define CTLS_RLBUFFERINFO 1
00108 #define CTLS_WIN32_COND 2
00109 #define CTLS_CSVTABLEPTR 3
00110 #define CTLS_CSVDEFAULTFILENAME 4
00111 #define CTLS_ERRORCONTEXT 5
00112 #define CTLS_UNUSED1 6
00113 #define CTLS_PATHBUF 7
00114 #define CTLS_UNUSED3 8
00115 #define CTLS_UNUSED4 9
00116 #define CTLS_CPLSPRINTF 10
00117 #define CTLS_RESPONSIBLEPID 11
00118 #define CTLS_VERSIONINFO 12
00119 #define CTLS_VERSIONINFO_LICENCE 13
00120 #define CTLS_CONFIGOPTIONS 14
00121 #define CTLS_FINDFILE 15
00122
00123 #define CTLS_MAX 32
00124
00125 CPL_C_START
00126 void CPL_DLL * CPLGetTLS( int nIndex );
00127 void CPL_DLL CPLSetTLS( int nIndex, void *pData, int bFreeOnExit );
00128
00129
00130
00131 typedef void (*CPLTLSFreeFunc)( void* pData );
00132 void CPL_DLL CPLSetTLSWithFreeFunc( int nIndex, void *pData, CPLTLSFreeFunc pfnFree );
00133
00134 void CPL_DLL CPLCleanupTLS();
00135 CPL_C_END
00136
00137 #endif