QtPass 1.5.1
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
simpletransaction.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#include "simpletransaction.h"
4#include <utility>
5
6#ifdef QT_DEBUG
7#include "debughelper.h"
8#endif
9
10using Enums::INVALID;
11using Enums::PROCESS;
12
17#ifdef QT_DEBUG
18 dbg() << "START" << transactionDepth;
19#endif
20 transactionDepth++;
21}
22
28#ifdef QT_DEBUG
29 dbg() << "ADD" << transactionDepth << id;
30#endif
31 if (transactionDepth > 0) {
32 lastInTransaction = id;
33 } else {
34 transactionQueue.emplace(id, id);
35 }
36}
37
43#ifdef QT_DEBUG
44 dbg() << "END" << transactionDepth;
45#endif
46 if (transactionDepth > 0) {
47 transactionDepth--;
48 if (transactionDepth == 0 && lastInTransaction != INVALID) {
49 transactionQueue.emplace(lastInTransaction, pid);
50 lastInTransaction = INVALID;
51 }
52 }
53}
54
60auto simpleTransaction::transactionIsOver(PROCESS id) -> PROCESS {
61#ifdef QT_DEBUG
62 dbg() << "OVER" << transactionDepth << id;
63#endif
64 if (!transactionQueue.empty() && id == transactionQueue.front().first) {
65 PROCESS ret = transactionQueue.front().second;
66 transactionQueue.pop();
67 return ret;
68 }
69 return INVALID;
70}
auto transactionIsOver(Enums::PROCESS) -> Enums::PROCESS
transactionIsOver checks wheather currently finished process is last in current transaction
void transactionEnd(Enums::PROCESS)
transactionEnd marks end of transaction
void transactionAdd(Enums::PROCESS)
transactionAdd If called after call to transactionStart() and before transactionEnd(),...
void transactionStart()
transactionStart this function is used to mark start of the sequence of processes that shall be treat...
#define dbg()
Definition debughelper.h:9
PROCESS
Definition enums.h:18
@ INVALID
Definition enums.h:35