Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
scoped_rwlock.h
1
2
/***************************************************************************
3
* scoped_rwlock.h - Scoped read/write lock
4
*
5
* Created: Mon Jan 10 11:42:56 2011
6
* Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version. A runtime exception applies to
14
* this software (see LICENSE.GPL_WRE file mentioned below for details).
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22
*/
23
24
#ifndef __CORE_THREADING_SCOPED_RWLOCK_H_
25
#define __CORE_THREADING_SCOPED_RWLOCK_H_
26
27
#include <core/utils/refptr.h>
28
29
namespace
fawkes {
30
31
class
ReadWriteLock;
32
33
class
ScopedRWLock
34
{
35
public
:
36
/** What to lock for. */
37
typedef
enum
{
38
LOCK_WRITE
,
///< Lock for writing
39
LOCK_READ
///< Lock for reading
40
}
LockType
;
41
42
ScopedRWLock
(
RefPtr<ReadWriteLock>
rwlock,
LockType
lock_type =
LOCK_WRITE
,
43
bool
initially_lock =
true
);
44
ScopedRWLock
(
ReadWriteLock
*rwlock,
LockType
lock_type =
LOCK_WRITE
,
45
bool
initially_lock =
true
);
46
~ScopedRWLock
();
47
48
void
relock
();
49
void
unlock
();
50
51
private
:
52
LockType
__lock_type;
53
bool
__locked;
54
RefPtr<ReadWriteLock>
__refrwlock;
55
ReadWriteLock
*__rawrwlock;
56
};
57
58
59
}
// end namespace fawkes
60
61
#endif
src
libs
core
threading
scoped_rwlock.h
Generated by
1.8.3.1