QGIS API Documentation
3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
src
core
qgsreadwritelocker.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsreadwritelocker.cpp
3
-------------------------
4
begin : September 2018
5
copyright : (C) 2018 by Matthias Kuhn
6
email :
[email protected]
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgsreadwritelocker.h
"
19
20
QgsReadWriteLocker::QgsReadWriteLocker
( QReadWriteLock &lock,
QgsReadWriteLocker::Mode
mode )
21
: mLock( lock )
22
, mMode( mode )
23
{
24
if
( mode ==
Read
)
25
mLock.lockForRead();
26
else
if
( mode ==
Write
)
27
mLock.lockForWrite();
28
}
29
30
void
QgsReadWriteLocker::changeMode
(
QgsReadWriteLocker::Mode
mode )
31
{
32
if
( mode == mMode )
33
return
;
34
35
unlock
();
36
37
mMode = mode;
38
39
if
( mMode ==
Read
)
40
mLock.lockForRead();
41
else
if
( mMode ==
Write
)
42
mLock.lockForWrite();
43
}
44
45
void
QgsReadWriteLocker::unlock
()
46
{
47
if
( mMode !=
Unlocked
)
48
mLock.unlock();
49
50
mMode =
Unlocked
;
51
}
52
53
QgsReadWriteLocker::~QgsReadWriteLocker
()
54
{
55
unlock
();
56
}
QgsReadWriteLocker::Mode
Mode
A QReadWriteLock can be in 3 different modes, read, write or unlocked.
Definition
qgsreadwritelocker.h:48
QgsReadWriteLocker::Unlocked
@ Unlocked
Unlocked.
Definition
qgsreadwritelocker.h:51
QgsReadWriteLocker::Write
@ Write
Lock for write.
Definition
qgsreadwritelocker.h:50
QgsReadWriteLocker::Read
@ Read
Lock for read.
Definition
qgsreadwritelocker.h:49
QgsReadWriteLocker::~QgsReadWriteLocker
~QgsReadWriteLocker()
Definition
qgsreadwritelocker.cpp:53
QgsReadWriteLocker::unlock
void unlock()
Unlocks the lock.
Definition
qgsreadwritelocker.cpp:45
QgsReadWriteLocker::changeMode
void changeMode(Mode mode)
Change the mode of the lock to mode.
Definition
qgsreadwritelocker.cpp:30
QgsReadWriteLocker::QgsReadWriteLocker
QgsReadWriteLocker(QReadWriteLock &lock, Mode mode)
Create a new QgsReadWriteLocker for lock and initialize in mode.
Definition
qgsreadwritelocker.cpp:20
qgsreadwritelocker.h
Generated on Tue Nov 19 2024 18:20:01 for QGIS API Documentation by
1.9.8