blob: 79a17b8c41056416226a00c13937e7acd6c90782 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "simpletransaction.h"
#include <utility>
#ifdef QT_DEBUG
#include "debughelper.h"
#endif
using std::pair;
using namespace Enums;
void simpleTransaction::transactionStart() {
#ifdef QT_DEBUG
dbg() << "START" << transactionDepth;
#endif
transactionDepth++;
}
void simpleTransaction::transactionAdd(PROCESS id) {
#ifdef QT_DEBUG
dbg() << "ADD" << transactionDepth << id;
#endif
if (transactionDepth > 0) {
lastInTransaction = id;
} else {
transactionQueue.push(pair<PROCESS, PROCESS>(id, id));
}
}
void simpleTransaction::transactionEnd(PROCESS pid) {
#ifdef QT_DEBUG
dbg() << "END" << transactionDepth;
#endif
if (transactionDepth > 0) {
transactionDepth--;
if (transactionDepth == 0 && lastInTransaction != INVALID) {
transactionQueue.push(pair<PROCESS, PROCESS>(lastInTransaction, pid));
lastInTransaction = INVALID;
}
}
}
PROCESS simpleTransaction::transactionIsOver(PROCESS id) {
#ifdef QT_DEBUG
dbg() << "OVER" << transactionDepth << id;
#endif
if (!transactionQueue.empty() && id == transactionQueue.front().first) {
PROCESS ret = transactionQueue.front().second;
transactionQueue.pop();
return ret;
}
return INVALID;
}
|