summaryrefslogtreecommitdiffstats
path: root/3rdparty/clucene/src/CLucene/config/threadPthread.h
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit50123887ba0f33cf47520bee7c419d68742af2d1 (patch)
tree0eb8679b9e4e4370e59b44bfdcae616816e39aca /3rdparty/clucene/src/CLucene/config/threadPthread.h
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to '3rdparty/clucene/src/CLucene/config/threadPthread.h')
-rw-r--r--3rdparty/clucene/src/CLucene/config/threadPthread.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/3rdparty/clucene/src/CLucene/config/threadPthread.h b/3rdparty/clucene/src/CLucene/config/threadPthread.h
new file mode 100644
index 000000000..d0ed9c4c9
--- /dev/null
+++ b/3rdparty/clucene/src/CLucene/config/threadPthread.h
@@ -0,0 +1,59 @@
+/*------------------------------------------------------------------------------
+* 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.
+------------------------------------------------------------------------------*/
+//NOTE: do not include this file directly, it is included from lucene internally.
+
+#ifndef lucene_config_threadPthread_h
+#define lucene_config_threadPthread_h
+
+#include <pthread.h>
+
+CL_NS_DEF(util)
+
+///a posix implementation of the lock mutex
+///todo: we need a spinlock implemenation for usage in reference counting
+class mutex_pthread
+{
+private:
+ pthread_mutex_t mtx;
+
+public:
+ mutex_pthread(const mutex_pthread& clone);
+ mutex_pthread();
+ ~mutex_pthread();
+ void lock();
+ void unlock();
+
+private:
+ #ifndef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE
+ pthread_t lockOwner;
+ unsigned int lockCount;
+ #endif
+};
+
+#define _LUCENE_SLEEP(x) usleep(x*1000) //_LUCENE_SLEEP should be in millis, usleep is in micros
+#define _LUCENE_THREADMUTEX CL_NS(util)::mutex_pthread
+#define _LUCENE_CURRTHREADID pthread_self()
+#define _LUCENE_THREADID_TYPE pthread_t
+
+class CLuceneThreadIdCompare
+{
+public:
+ enum
+ { // parameters for hash table
+ bucket_size = 4, // 0 < bucket_size
+ min_buckets = 8
+ }; // min_buckets = 2 ^^ N, 0 < N
+
+ bool operator()( pthread_t t1, pthread_t t2 ) const{
+ return t1 < t2;
+ }
+};
+
+
+CL_NS_END
+
+#endif //lucene_config_threadPthread_h