Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
operation-blocker.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef SEEN_OPERATION_BLOCKER_H
4#define SEEN_OPERATION_BLOCKER_H
5
6// cooperative counter-based pending operation blocking
7
9public:
10 OperationBlocker() = default;
11
12 bool pending() const {
13 return _counter > 0;
14 }
15
17 public:
18 scoped_block(unsigned int& counter): _c(counter) {
19 ++_c;
20 }
21
23 --_c;
24 }
25
26 private:
27 unsigned int& _c;
28 };
29
30 [[nodiscard]] scoped_block block() {
31 return scoped_block(_counter);
32 }
33
34private:
35 unsigned int _counter = 0;
36};
37
38#endif
scoped_block(unsigned int &counter)
OperationBlocker()=default
scoped_block block()
unsigned int _counter
static gint counter
Definition box3d.cpp:39