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
read_write_lock.h
1
2
/***************************************************************************
3
* read_write_lock.h - Read Write Lock
4
*
5
* Generated: Thu Sep 15 00:07:41 2006
6
* Copyright 2006 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_READ_WRITE_LOCK_H_
25
#define __CORE_THREADING_READ_WRITE_LOCK_H_
26
27
namespace
fawkes {
28
29
30
class
ReadWriteLockData;
31
32
class
ReadWriteLock
33
{
34
public
:
35
36
/** The policy to use for the read/write lock.
37
*/
38
enum
ReadWriteLockPolicy
{
39
RWLockPolicyPreferWriter
,
/**< Prefer writers over readers. A writer
40
* is granted prefered access to the lock.
41
* This means that the writer can aquire
42
* the lock as soon as all readers unlocked
43
* it not matter if there are readers queued
44
* and waiting for the lock. This is the
45
* default behaviour. Not with multiple
46
* writers you can run into the problem of
47
* reader starvation.
48
*/
49
RWLockPolicyPreferReader
/**< Prefer readers over writers. This is
50
* similar to the writer preference. Readers
51
* will be allowed to aquire the lock no
52
* matter if there is a writer enqueued for
53
* the lock. Not that with many readers
54
* (depending on the time they aquire the
55
* lock this can already start with two
56
* or three readers) you can run into the
57
* problem of writer starvation: the writer
58
* can never aquire the lock.
59
*/
60
};
61
62
ReadWriteLock
(
ReadWriteLockPolicy
policy =
RWLockPolicyPreferWriter
);
63
64
virtual
~ReadWriteLock
();
65
66
void
lock_for_read
();
67
void
lock_for_write
();
68
bool
try_lock_for_read
();
69
bool
try_lock_for_write
();
70
void
unlock
();
71
72
private
:
73
ReadWriteLockData *rwlock_data;
74
};
75
76
77
}
// end namespace fawkes
78
79
#endif
src
libs
core
threading
read_write_lock.h
Generated by
1.8.3.1