Lucene++ - a full-featured, c++ search engine
API Documentation

Synchronize.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6
7 #ifndef SYNCHRONIZE_H
8 #define SYNCHRONIZE_H
9
10 #include <boost/thread/recursive_mutex.hpp>
11 #include "Lucene.h"
12
13 namespace Lucene {
14
16 class LPPAPI Synchronize {
17 public:
18 Synchronize();
19 virtual ~Synchronize();
20
21 protected:
22 boost::recursive_timed_mutex mutexSynchronize;
23 int64_t lockThread;
24 int32_t recursionCount;
25
26 public:
28 static void createSync(SynchronizePtr& sync);
29
31 void lock(int32_t timeout = 0);
32
34 void unlock();
35
37 int32_t unlockAll();
38
40 bool holdsLock();
41 };
42
44 class LPPAPI SyncLock {
45 public:
46 SyncLock(const SynchronizePtr& sync, int32_t timeout = 0);
47
48 template <class OBJECT>
49 SyncLock(OBJECT object, int32_t timeout = 0) {
50 this->sync = object->getSync();
51 lock(timeout);
52 }
53
54 virtual ~SyncLock();
55
56 protected:
57 SynchronizePtr sync;
58
59 protected:
60 void lock(int32_t timeout);
61 };
62
63 }
64
65 #endif
Lucene::SyncLock::SyncLock
SyncLock(OBJECT object, int32_t timeout=0)
Definition: Synchronize.h:49
Lucene::SyncLock
Utility class to support scope locking.
Definition: Synchronize.h:44
Lucene::Synchronize::lockThread
int64_t lockThread
Definition: Synchronize.h:23
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::Synchronize::recursionCount
int32_t recursionCount
Definition: Synchronize.h:24
Lucene::SyncLock::sync
SynchronizePtr sync
Definition: Synchronize.h:57
Lucene::Synchronize
Utility class to support locking via a mutex.
Definition: Synchronize.h:16
Lucene::Synchronize::mutexSynchronize
boost::recursive_timed_mutex mutexSynchronize
Definition: Synchronize.h:22
Lucene::SynchronizePtr
boost::shared_ptr< Synchronize > SynchronizePtr
Definition: LuceneTypes.h:552

clucene.sourceforge.net