- Main Page
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# cpl_multiproc.h

    00001 /**********************************************************************
    00002  * $Id: cpl_multiproc.h,v 1.10 2006/01/25 19:52:25 fwarmerdam Exp $
    00003  *
    00004  * Project:  CPL - Common Portability Library
    00005  * Purpose:  CPL Multi-Threading, and process handling portability functions.
    00006  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00007  *
    00008  **********************************************************************
    00009  * Copyright (c) 2002, Frank Warmerdam
    00010  *
    00011  * Permission is hereby granted, free of charge, to any person obtaining a
    00012  * copy of this software and associated documentation files (the "Software"),
    00013  * to deal in the Software without restriction, including without limitation
    00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00015  * and/or sell copies of the Software, and to permit persons to whom the
    00016  * Software is furnished to do so, subject to the following conditions:
    00017  *
    00018  * The above copyright notice and this permission notice shall be included
    00019  * in all copies or substantial portions of the Software.
    00020  *
    00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00022  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
    00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00027  * DEALINGS IN THE SOFTWARE.
    00028  **********************************************************************
    00029  *
    00030  * $Log: cpl_multiproc.h,v $
    00031  * Revision 1.10  2006/01/25 19:52:25  fwarmerdam
    00032  * default to avoiding as much mutex overhead as opposed if MUTEX_NONE defined
    00033  *
    00034  * Revision 1.9  2005/08/24 22:19:27  fwarmerdam
    00035  * added CPLCleanupTLS
    00036  *
    00037  * Revision 1.8  2005/07/08 18:17:52  fwarmerdam
    00038  * complete TLS implementation for win32
    00039  *
    00040  * Revision 1.7  2005/07/08 14:35:26  fwarmerdam
    00041  * preliminary TLS support
    00042  *
    00043  * Revision 1.6  2005/05/23 06:39:49  fwarmerdam
    00044  * added CPLMutexHolder stuff
    00045  *
    00046  * Revision 1.5  2005/05/20 19:19:00  fwarmerdam
    00047  * added CPLCreateOrAcquireMutex()
    00048  *
    00049  * Revision 1.4  2005/04/26 20:52:10  fwarmerdam
    00050  * use a typedef type for thread mains (for Sun port)
    00051  *
    00052  * Revision 1.3  2003/04/23 04:36:55  warmerda
    00053  * pthreads based implementation
    00054  *
    00055  * Revision 1.2  2002/05/24 04:09:24  warmerda
    00056  * fixed CPL_DLL declarations
    00057  *
    00058  * Revision 1.1  2002/05/24 04:01:01  warmerda
    00059  * New
    00060  *
    00061  **********************************************************************/
    00062
    00063 #ifndef _CPL_MULTIPROC_H_INCLUDED_
    00064 #define _CPL_MULTIPROC_H_INCLUDED_
    00065
    00066 #include "cpl_port.h"
    00067
    00068 // There are three primary implementations of the multi-process support
    00069 // controlled by one of CPL_MULTIPROC_WIN32, CPL_MULTIPROC_PTHREAD or
    00070 // CPL_MULTIPROC_STUB being defined.  If none are defined, the stub
    00071 // implementation will be used.
    00072
    00073 #if defined(WIN32) && !defined(CPL_MULTIPROC_STUB)
    00074 #  define CPL_MULTIPROC_WIN32
    00075 #endif
    00076
    00077 #if !defined(CPL_MULTIPROC_WIN32) && !defined(CPL_MULTIPROC_PTHREAD) \
    00078  && !defined(CPL_MULTIPROC_STUB) && !defined(CPL_MULTIPROC_NONE)
    00079 #  define CPL_MULTIPROC_STUB
    00080 #endif
    00081
    00082 CPL_C_START
    00083
    00084 typedef void (*CPLThreadFunc)(void *);
    00085
    00086 void CPL_DLL *CPLLockFile( const char *pszPath, double dfWaitInSeconds );
    00087 void  CPL_DLL CPLUnlockFile( void *hLock );
    00088
    00089 void CPL_DLL *CPLCreateMutex();
    00090 int   CPL_DLL CPLCreateOrAcquireMutex( void **, double dfWaitInSeconds );
    00091 int   CPL_DLL CPLAcquireMutex( void *hMutex, double dfWaitInSeconds );
    00092 void  CPL_DLL CPLReleaseMutex( void *hMutex );
    00093 void  CPL_DLL CPLDestroyMutex( void *hMutex );
    00094
    00095 int   CPL_DLL CPLGetPID();
    00096 int   CPL_DLL CPLCreateThread( CPLThreadFunc pfnMain, void *pArg );
    00097 void  CPL_DLL CPLSleep( double dfWaitInSeconds );
    00098
    00099 const char CPL_DLL *CPLGetThreadingModel();
    00100
    00101 CPL_C_END
    00102
    00103 #ifdef __cplusplus
    00104
    00105 #define CPLMutexHolderD(x)  CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__);
    00106
    00107 class CPLMutexHolder
    00108 {
    00109   private:
    00110     void       *hMutex;
    00111     const char *pszFile;
    00112     int         nLine;
    00113
    00114   public:
    00115
    00116     CPLMutexHolder( void **phMutex, double dfWaitInSeconds = 1000.0,
    00117                     const char *pszFile = __FILE__,
    00118                     int nLine = __LINE__ );
    00119     ~CPLMutexHolder();
    00120 };
    00121 #endif /* def __cplusplus */
    00122
    00123 /* -------------------------------------------------------------------- */
    00124 /*      Thread local storage.                                           */
    00125 /* -------------------------------------------------------------------- */
    00126
    00127 #define CTLS_RLBUFFERINFO               1         /* cpl_conv.cpp */
    00128 #define CTLS_DECDMSBUFFER               2         /* cpl_conv.cpp */
    00129 #define CTLS_CSVTABLEPTR                3         /* cpl_csv.cpp */
    00130 #define CTLS_CSVDEFAULTFILENAME         4         /* cpl_csv.cpp */
    00131 #define CTLS_ERRORCONTEXT               5         /* cpl_error.cpp */
    00132 #define CTLS_FINDERINFO                 6         /* cpl_finder.cpp */
    00133 #define CTLS_PATHBUF                    7         /* cpl_path.cpp */
    00134 #define CTLS_SPRINTFBUF                 8         /* cpl_string.cpp */
    00135
    00136 #define CTLS_MAX                       32
    00137
    00138 CPL_C_START
    00139 void CPL_DLL * CPLGetTLS( int nIndex );
    00140 void CPL_DLL CPLSetTLS( int nIndex, void *pData, int bFreeOnExit );
    00141 void CPL_DLL CPLCleanupTLS();
    00142 CPL_C_END
    00143
    00144 #endif /* _CPL_MULTIPROC_H_INCLUDED_ */

Generated for GDAL by 1.4.5.