Lucene++ - a full-featured, c++ search engine
API Documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
include
Synchronize.h
Go to the documentation of this file.
1
2
// 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
clucene.sourceforge.net