31#ifndef CPL_MULTIPROC_H_INCLUDED_
32#define CPL_MULTIPROC_H_INCLUDED_
43#if defined(WIN32) && !defined(CPL_MULTIPROC_STUB)
44# define CPL_MULTIPROC_WIN32
47# undef CPL_MULTIPROC_PTHREAD
50#if !defined(CPL_MULTIPROC_WIN32) && !defined(CPL_MULTIPROC_PTHREAD) \
51 && !defined(CPL_MULTIPROC_STUB) && !defined(CPL_MULTIPROC_NONE)
52# define CPL_MULTIPROC_STUB
57typedef void (*CPLThreadFunc)(
void *);
59void CPL_DLL *CPLLockFile(
const char *pszPath,
double dfWaitInSeconds );
60void CPL_DLL CPLUnlockFile(
void *hLock );
63typedef struct _CPLMutex CPLMutex;
64typedef struct _CPLCond CPLCond;
65typedef struct _CPLJoinableThread CPLJoinableThread;
69#define CPLJoinableThread void
73#define CPL_MUTEX_RECURSIVE 0
74#define CPL_MUTEX_ADAPTIVE 1
75#define CPL_MUTEX_REGULAR 2
77CPLMutex CPL_DLL *CPLCreateMutex(
void );
78CPLMutex CPL_DLL *CPLCreateMutexEx(
int nOptions );
79int CPL_DLL CPLCreateOrAcquireMutex( CPLMutex **,
double dfWaitInSeconds );
80int CPL_DLL CPLCreateOrAcquireMutexEx( CPLMutex **,
double dfWaitInSeconds,
int nOptions );
81int CPL_DLL CPLAcquireMutex( CPLMutex *hMutex,
double dfWaitInSeconds );
82void CPL_DLL CPLReleaseMutex( CPLMutex *hMutex );
83void CPL_DLL CPLDestroyMutex( CPLMutex *hMutex );
84void CPL_DLL CPLCleanupMasterMutex(
void );
86CPLCond CPL_DLL *CPLCreateCond(
void );
87void CPL_DLL CPLCondWait( CPLCond *hCond, CPLMutex* hMutex );
91 COND_TIMED_WAIT_TIME_OUT,
93} CPLCondTimedWaitReason;
94CPLCondTimedWaitReason CPL_DLL CPLCondTimedWait( CPLCond *hCond, CPLMutex* hMutex,
double dfWaitInSeconds );
95void CPL_DLL CPLCondSignal( CPLCond *hCond );
96void CPL_DLL CPLCondBroadcast( CPLCond *hCond );
97void CPL_DLL CPLDestroyCond( CPLCond *hCond );
100GIntBig CPL_DLL CPLGetPID(
void );
101int CPL_DLL CPLGetCurrentProcessID(
void );
102int CPL_DLL CPLCreateThread( CPLThreadFunc pfnMain,
void *pArg );
103CPLJoinableThread CPL_DLL* CPLCreateJoinableThread( CPLThreadFunc pfnMain,
void *pArg );
104void CPL_DLL CPLJoinThread(CPLJoinableThread* hJoinableThread);
105void CPL_DLL CPLSleep(
double dfWaitInSeconds );
107const char CPL_DLL *CPLGetThreadingModel(
void );
109int CPL_DLL CPLGetNumCPUs(
void );
111typedef struct _CPLLock CPLLock;
118 LOCK_RECURSIVE_MUTEX,
123CPLLock CPL_DLL *CPLCreateLock( CPLLockType eType );
124int CPL_DLL CPLCreateOrAcquireLock( CPLLock**, CPLLockType eType );
125int CPL_DLL CPLAcquireLock( CPLLock* );
126void CPL_DLL CPLReleaseLock( CPLLock* );
127void CPL_DLL CPLDestroyLock( CPLLock* );
128void CPL_DLL CPLLockSetDebugPerf( CPLLock*,
int bEnableIn );
132#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
135#define CPLMutexHolderD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__)
139#define CPLMutexHolderExD(x, nOptions) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__,nOptions)
143#define CPLMutexHolderOptionalLockD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__)
149 CPLMutex *hMutex =
nullptr;
151 const char *pszFile =
nullptr;
159 explicit CPLMutexHolder( CPLMutex **phMutex,
double dfWaitInSeconds = 1000.0,
160 const char *pszFile = __FILE__,
161 int nLine = __LINE__,
162 int nOptions = CPL_MUTEX_RECURSIVE);
166 explicit CPLMutexHolder( CPLMutex* hMutex,
double dfWaitInSeconds = 1000.0,
167 const char *pszFile = __FILE__,
168 int nLine = __LINE__ );
174#define CPLLockHolderD(x, eType) CPLLockHolder oHolder(x,eType,__FILE__,__LINE__);
178#define CPLLockHolderOptionalLockD(x) CPLLockHolder oHolder(x,__FILE__,__LINE__);
184 CPLLock *hLock =
nullptr;
185 const char *pszFile =
nullptr;
194 const char *pszFile = __FILE__,
195 int nLine = __LINE__);
200 const char *pszFile = __FILE__,
201 int nLine = __LINE__ );
212#define CTLS_RLBUFFERINFO 1
213#define CTLS_WIN32_COND 2
214#define CTLS_CSVTABLEPTR 3
215#define CTLS_CSVDEFAULTFILENAME 4
216#define CTLS_ERRORCONTEXT 5
217#define CTLS_VSICURL_CACHEDCONNECTION 6
218#define CTLS_PATHBUF 7
219#define CTLS_ABSTRACTARCHIVE_SPLIT 8
220#define CTLS_GDALOPEN_ANTIRECURSION 9
221#define CTLS_CPLSPRINTF 10
222#define CTLS_RESPONSIBLEPID 11
223#define CTLS_VERSIONINFO 12
224#define CTLS_VERSIONINFO_LICENCE 13
225#define CTLS_CONFIGOPTIONS 14
226#define CTLS_FINDFILE 15
227#define CTLS_VSIERRORCONTEXT 16
228#define CTLS_ERRORHANDLERACTIVEDATA 17
229#define CTLS_PROJCONTEXTHOLDER 18
230#define CTLS_GDALDEFAULTOVR_ANTIREC 19
231#define CTLS_HTTPFETCHCALLBACK 20
236void CPL_DLL * CPLGetTLS(
int nIndex );
237void CPL_DLL * CPLGetTLSEx(
int nIndex,
int* pbMemoryErrorOccurred );
238void CPL_DLL CPLSetTLS(
int nIndex,
void *pData,
int bFreeOnExit );
242typedef void (*CPLTLSFreeFunc)(
void* pData );
243void CPL_DLL CPLSetTLSWithFreeFunc(
int nIndex,
void *pData, CPLTLSFreeFunc pfnFree );
244void CPL_DLL CPLSetTLSWithFreeFuncEx(
int nIndex,
void *pData, CPLTLSFreeFunc pfnFree,
int* pbMemoryErrorOccurred );
246void CPL_DLL CPLCleanupTLS(
void );
CPLLockHolder(CPLLock **phSpin, CPLLockType eType, const char *pszFile=__FILE__, int nLine=__LINE__)
Instantiates the lock if not already done.
Definition cpl_multiproc.cpp:2679
CPLMutexHolder(CPLMutex **phMutex, double dfWaitInSeconds=1000.0, const char *pszFile=__FILE__, int nLine=__LINE__, int nOptions=CPL_MUTEX_RECURSIVE)
Instantiates the mutex if not already done.
Definition cpl_multiproc.cpp:171
Core portability definitions for CPL.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:331
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:329
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:955
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:244