QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
qgsreadwritelocker.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsreadwritelocker.cpp
3 -------------------------
4 begin : September 2018
5 copyright : (C) 2018 by Matthias Kuhn
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#ifndef QGSREADWRITELOCKER_H
19#define QGSREADWRITELOCKER_H
20
21#include "qgis_core.h"
22
23#include <QReadWriteLock>
24
40class CORE_EXPORT QgsReadWriteLocker
41{
42 public:
46 enum Mode
47 {
51 };
52
56 QgsReadWriteLocker( QReadWriteLock &lock, Mode mode );
57
62 void changeMode( Mode mode );
63
68 void unlock();
69
71
72 private:
73#ifdef SIP_RUN
74 QgsReadWriteLocker &operator=( const QgsReadWriteLocker & );
75#endif
76
77 QReadWriteLock &mLock;
78 Mode mMode = Unlocked;
79};
80
81#endif // QGSREADWRITELOCKER_H
A convenience class that simplifies locking and unlocking QReadWriteLocks.
Mode
A QReadWriteLock can be in 3 different modes, read, write or unlocked.
@ Write
Lock for write.
QgsReadWriteLocker(QReadWriteLock &lock, Mode mode)
Create a new QgsReadWriteLocker for lock and initialize in mode.