QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
simpletransaction.cpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2017 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
8
#include "
simpletransaction.h
"
9
#include <utility>
10
11
#include "
qtpasslogging.h
"
12
13
using
Enums::INVALID
;
14
using
Enums::PROCESS
;
15
16
void
SimpleTransaction::transactionStart
() {
17
qCDebug(lcQtPass) <<
"START"
<<
transactionDepth
;
18
transactionDepth
++;
19
}
20
21
void
SimpleTransaction::transactionAdd
(
PROCESS
id
) {
22
qCDebug(lcQtPass) <<
"ADD"
<<
transactionDepth
<< id;
23
if
(
transactionDepth
> 0) {
24
lastInTransaction
= id;
25
}
else
{
26
transactionQueue
.emplace(
id
,
id
);
27
}
28
}
29
30
void
SimpleTransaction::transactionEnd
(
PROCESS
pid) {
31
qCDebug(lcQtPass) <<
"END"
<<
transactionDepth
;
32
if
(
transactionDepth
> 0) {
33
transactionDepth
--;
34
if
(
transactionDepth
== 0 &&
lastInTransaction
!=
INVALID
) {
35
transactionQueue
.emplace(
lastInTransaction
, pid);
36
lastInTransaction
=
INVALID
;
37
}
38
}
39
}
40
41
auto
SimpleTransaction::transactionIsOver
(
PROCESS
id
) ->
PROCESS
{
42
qCDebug(lcQtPass) <<
"OVER"
<<
transactionDepth
<< id;
43
if
(!
transactionQueue
.empty() &&
id
==
transactionQueue
.front().first) {
44
PROCESS
ret =
transactionQueue
.front().second;
45
transactionQueue
.pop();
46
return
ret;
47
}
48
return
INVALID
;
49
}
SimpleTransaction::transactionAdd
void transactionAdd(Enums::PROCESS process)
Note that process has been queued.
Definition
simpletransaction.cpp:21
SimpleTransaction::transactionIsOver
auto transactionIsOver(Enums::PROCESS current) -> Enums::PROCESS
Tell whether the process that just finished ends the oldest pending transaction, and take that transa...
Definition
simpletransaction.cpp:41
SimpleTransaction::transactionStart
void transactionStart()
Open a transaction: the processes added until the matching transactionEnd() are reported as one opera...
Definition
simpletransaction.cpp:16
SimpleTransaction::transactionEnd
void transactionEnd(Enums::PROCESS process)
Close the transaction opened by the matching transactionStart().
Definition
simpletransaction.cpp:30
SimpleTransaction::transactionDepth
int transactionDepth
How many transactionStart() calls are still open.
Definition
simpletransaction.h:31
SimpleTransaction::transactionQueue
std::queue< std::pair< Enums::PROCESS, Enums::PROCESS > > transactionQueue
Closed transactions awaiting completion, oldest first: the process that ends each one,...
Definition
simpletransaction.h:41
SimpleTransaction::lastInTransaction
Enums::PROCESS lastInTransaction
The process most recently added to the open transaction, or Enums::INVALID when none was added yet.
Definition
simpletransaction.h:36
INVALID
@ INVALID
Definition
enums.h:63
Enums::PROCESS
PROCESS
Identifies different subprocess operations used in QtPass.
Definition
enums.h:43
Enums::INVALID
@ INVALID
Definition
enums.h:63
qtpasslogging.h
The "qtpass" logging category.
simpletransaction.h
SimpleTransaction, the bookkeeping that lets ImitatePass report several queued processes as one finis...
src
simpletransaction.cpp
Generated by
1.18.0