00001 /********************************************************************** 00002 * $Id: cpl_multiproc.h,v 1.3 2003/04/23 04:36:55 warmerda 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.3 2003/04/23 04:36:55 warmerda 00032 * pthreads based implementation 00033 * 00034 * Revision 1.2 2002/05/24 04:09:24 warmerda 00035 * fixed CPL_DLL declarations 00036 * 00037 * Revision 1.1 2002/05/24 04:01:01 warmerda 00038 * New 00039 * 00040 **********************************************************************/ 00041 00042 #ifndef _CPL_MULTIPROC_H_INCLUDED_ 00043 #define _CPL_MULTIPROC_H_INCLUDED_ 00044 00045 #include "cpl_port.h" 00046 00047 // There are three primary implementations of the multi-process support 00048 // controlled by one of CPL_MULTIPROC_WIN32, CPL_MULTIPROC_PTHREAD or 00049 // CPL_MULTIPROC_STUB being defined. If none are defined, the stub 00050 // implementation will be used. 00051 00052 #if defined(WIN32) && !defined(CPL_MULTIPROC_STUB) 00053 # define CPL_MULTIPROC_WIN32 00054 #endif 00055 00056 #if !defined(CPL_MULTIPROC_WIN32) && !defined(CPL_MULTIPROC_PTHREAD) \ 00057 && !defined(CPL_MULTIPROC_STUB) 00058 # define CPL_MULTIPROC_STUB 00059 #endif 00060 00061 CPL_C_START 00062 00063 void CPL_DLL *CPLLockFile( const char *pszPath, double dfWaitInSeconds ); 00064 void CPL_DLL CPLUnlockFile( void *hLock ); 00065 00066 void CPL_DLL *CPLCreateMutex(); 00067 int CPL_DLL CPLAcquireMutex( void *hMutex, double dfWaitInSeconds ); 00068 void CPL_DLL CPLReleaseMutex( void *hMutex ); 00069 void CPL_DLL CPLDestroyMutex( void *hMutex ); 00070 00071 int CPL_DLL CPLGetPID(); 00072 int CPL_DLL CPLCreateThread( void (*pfnMain)(void *), void *pArg ); 00073 void CPL_DLL CPLSleep( double dfWaitInSeconds ); 00074 00075 const char CPL_DLL *CPLGetThreadingModel(); 00076 00077 CPL_C_END 00078 00079 #endif /* _CPL_MULTIPROC_H_INCLUDED_ */