QGIS API Documentation
3.4.15-Madeira (e83d02e274)
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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.h
QgsReadWriteLocker::Unlocked
Unlocked.
Definition:
qgsreadwritelocker.h:51
QgsReadWriteLocker::Mode
Mode
A QReadWriteLock can be in 3 different modes, read, write or unlocked.
Definition:
qgsreadwritelocker.h:47
QgsReadWriteLocker::QgsReadWriteLocker
QgsReadWriteLocker(QReadWriteLock &lock, Mode mode)
Create a new QgsReadWriteLocker for lock and initialize in mode.
Definition:
qgsreadwritelocker.cpp:20
QgsReadWriteLocker::Read
Lock for read.
Definition:
qgsreadwritelocker.h:49
QgsReadWriteLocker::~QgsReadWriteLocker
~QgsReadWriteLocker()
Definition:
qgsreadwritelocker.cpp:53
QgsReadWriteLocker::Write
Lock for write.
Definition:
qgsreadwritelocker.h:50
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
Generated on Sun Jan 19 2020 15:27:13 for QGIS API Documentation by
1.8.11