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
// Copyright (c) 2009-2011 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
{
18
public
:
19
Synchronize
();
20
virtual
~
Synchronize
();
21
22
protected
:
23
boost::recursive_timed_mutex
mutexSynchronize
;
24
int64_t
lockThread
;
25
int32_t
recursionCount
;
26
27
public
:
29
static
void
createSync(
SynchronizePtr
& sync);
30
32
void
lock(int32_t timeout = 0);
33
35
void
unlock();
36
38
int32_t unlockAll();
39
41
bool
holdsLock();
42
};
43
45
class
LPPAPI
SyncLock
46
{
47
public
:
48
SyncLock
(
SynchronizePtr
sync, int32_t timeout = 0);
49
50
template
<
class
OBJECT>
51
SyncLock
(OBJECT
object
, int32_t timeout = 0)
52
{
53
this->sync =
object
->getSync();
54
lock(timeout);
55
}
56
57
virtual
~
SyncLock
();
58
59
protected
:
60
SynchronizePtr
sync
;
61
62
protected
:
63
void
lock(int32_t timeout);
64
};
65
}
66
67
#endif
clucene.sourceforge.net