QGIS API Documentation
3.14.0-Pi (9f7028fd23)
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::changeMode
void changeMode(Mode mode)
Change the mode of the lock to mode.
Definition:
qgsreadwritelocker.cpp:30
qgsreadwritelocker.h
QgsReadWriteLocker::Read
@ Read
Lock for read.
Definition:
qgsreadwritelocker.h:75
QgsReadWriteLocker::QgsReadWriteLocker
QgsReadWriteLocker(QReadWriteLock &lock, Mode mode)
Create a new QgsReadWriteLocker for lock and initialize in mode.
Definition:
qgsreadwritelocker.cpp:20
QgsReadWriteLocker::unlock
void unlock()
Unlocks the lock.
Definition:
qgsreadwritelocker.cpp:45
QgsReadWriteLocker::Write
@ Write
Lock for write.
Definition:
qgsreadwritelocker.h:76
QgsReadWriteLocker::Mode
Mode
A QReadWriteLock can be in 3 different modes, read, write or unlocked.
Definition:
qgsreadwritelocker.h:60
QgsReadWriteLocker::~QgsReadWriteLocker
~QgsReadWriteLocker()
Definition:
qgsreadwritelocker.cpp:53
QgsReadWriteLocker::Unlocked
@ Unlocked
Unlocked.
Definition:
qgsreadwritelocker.h:77
Generated on Mon Jun 22 2020 05:14:09 for QGIS API Documentation by
1.8.17