blob: 8567edcbfcdf5f8e6169e42cd6863f8ae8d3dac2 (
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
|
#ifndef SIMPLETRANSACTION_H
#define SIMPLETRANSACTION_H
#include "enums.h"
#include <queue>
class simpleTransaction {
int transactionDepth;
Enums::PROCESS lastInTransaction;
std::queue<std::pair<Enums::PROCESS, Enums::PROCESS> > transactionQueue;
public:
simpleTransaction()
: transactionDepth(0), lastInTransaction(Enums::INVALID) {}
/**
* @brief transactionStart this function is used to mark start of the sequence
* of processes that shall be treated as one
* operation.
*/
void transactionStart();
/**
* @brief transactionAdd If called after call to transactionStart() and before
* transactionEnd(), this method marks given process as
* next step in transaction. Otherwise it marks given
* process as the only step in transaction(it's value is
* treated as transaction result).
*
* @param id process that shall be treated as part of transaction
*/
void transactionAdd(Enums::PROCESS);
/**
* @brief transactionEnd marks end of transaction
*
* @param pid value that will be used as a result of transaction
*/
void transactionEnd(Enums::PROCESS);
/**
* @brief transactionIsOver checks wheather currently finished process is last
* in current transaction
*
* @return result of transaction as set by transactionAdd or transactionEnd if
* the transaction is over or PROCESS::INVALID if it's not yet over
*/
Enums::PROCESS transactionIsOver(Enums::PROCESS);
};
#endif // SIMPLETRANSACTION_H
|