/*------------------------------------------------------------------------------ * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team * * Distributable under the terms of either the Apache License (Version 2.0) or * the GNU Lesser General Public License, as specified in the COPYING file. ------------------------------------------------------------------------------*/ #ifndef _LuceneThreads_h #define _LuceneThreads_h #if defined(_LUCENE_PRAGMA_ONCE) # pragma once #endif #if defined(_CL_DISABLE_MULTITHREADING) #define SCOPED_LOCK_MUTEX(theMutex) #define SCOPED_LOCK_MUTEX_EX(theMutex,mutexname,dummy) #define DEFINE_MUTEX(x) #define STATIC_DEFINE_MUTEX(x) #else #if defined(_LUCENE_DONTIMPLEMENT_THREADMUTEX) //do nothing #elif defined(_CL_HAVE_PTHREAD) #include "CLucene/config/threadPthread.h" #elif defined(_CLCOMPILER_MSVC) || defined(__MINGW32__) //note that mingw32 could have pthreads, so put this after. #include "CLucene/config/threadCSection.h" #else #error A valid thread library was not found #endif //mutex types CL_NS_DEF(util) class mutexGuard { private: _LUCENE_THREADMUTEX* mrMutex; mutexGuard(const mutexGuard& clone); public: mutexGuard( _LUCENE_THREADMUTEX& rMutex ); ~mutexGuard(); }; CL_NS_END #define SCOPED_LOCK_MUTEX(theMutex) CL_NS(util)::mutexGuard theMutexGuard(theMutex); #define DEFINE_MUTEX(theMutex) _LUCENE_THREADMUTEX theMutex; #define STATIC_DEFINE_MUTEX(theMutex) static _LUCENE_THREADMUTEX theMutex; #endif //_CL_DISABLE_MULTITHREADING #endif