libcrn
3.9.5
A document image processing library
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
libcrn
CRNUtils
CRNRWLock.h
Go to the documentation of this file.
1
/* Copyright 2011-2015 CoReNum, INSA-Lyon
2
*
3
* This file is part of libcrn.
4
*
5
* libcrn is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* libcrn is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17
*
18
* file: CRNRWLock.h
19
* \author Yann LEYDIER
20
*/
21
22
#ifndef CRNRWLock_HEADER
23
#define CRNRWLock_HEADER
24
25
#include <CRN.h>
26
27
namespace
crn
28
{
37
class
RWLock
38
{
39
public
:
41
RWLock
();
43
~RWLock
();
44
RWLock
(
const
RWLock
&) =
delete
;
45
RWLock
(
RWLock
&&) =
delete
;
46
RWLock
&
operator=
(
const
RWLock
&) =
delete
;
47
RWLock
&
operator=
(
RWLock
&&) =
delete
;
48
50
void
WaitReadLock
();
52
void
ReadUnlock
();
53
55
void
WaitWriteLock
();
57
void
WriteUnlock
();
58
60
class
ReadLock
61
{
62
public
:
64
ReadLock
(
RWLock
&l):lock(l) { lock.
WaitReadLock
(); }
66
~ReadLock
() { lock.
ReadUnlock
(); }
67
private
:
68
RWLock
&lock;
69
};
70
72
class
WriteLock
73
{
74
public
:
76
WriteLock
(
RWLock
&l):lock(l) { lock.
WaitWriteLock
(); }
78
~WriteLock
() { lock.
WriteUnlock
(); }
79
private
:
80
RWLock
&lock;
81
};
82
83
private
:
84
struct
internal_data;
85
std::unique_ptr<internal_data> data;
86
};
87
}
88
89
#endif
90
crn::RWLock
A lock that allows multiple readers or one exclusive writer.
Definition:
CRNRWLock.h:37
crn::RWLock::WriteUnlock
void WriteUnlock()
Releases write token.
Definition:
CRNRWLock.cpp:195
crn::RWLock::ReadLock
RA2I read auto-lock.
Definition:
CRNRWLock.h:60
crn::RWLock::RWLock
RWLock()
Constructor.
Definition:
CRNRWLock.cpp:47
crn::RWLock::ReadLock::ReadLock
ReadLock(RWLock &l)
Locks.
Definition:
CRNRWLock.h:64
crn::RWLock::WriteLock::~WriteLock
~WriteLock()
Unlocks.
Definition:
CRNRWLock.h:78
crn::RWLock::~RWLock
~RWLock()
Destructor.
Definition:
CRNRWLock.cpp:62
crn::RWLock::WriteLock
RA2I write auto-lock.
Definition:
CRNRWLock.h:72
crn::RWLock::operator=
RWLock & operator=(const RWLock &)=delete
crn::RWLock::WaitWriteLock
void WaitWriteLock()
Requests authorization to write.
Definition:
CRNRWLock.cpp:149
crn::RWLock::WaitReadLock
void WaitReadLock()
Requests authorization to read.
Definition:
CRNRWLock.cpp:74
crn::RWLock::WriteLock::WriteLock
WriteLock(RWLock &l)
Locks.
Definition:
CRNRWLock.h:76
crn::RWLock::ReadLock::~ReadLock
~ReadLock()
Unlocks.
Definition:
CRNRWLock.h:66
crn::RWLock::ReadUnlock
void ReadUnlock()
Releases read token.
Definition:
CRNRWLock.cpp:121
Generated on Thu Sep 7 2017 13:54:26 for libcrn by
1.8.6