|
QtPass 2.0.0
Developer documentation
|
Tracks a sequence of processes that should be treated as one atomic operation. More...
#include <simpletransaction.h>
Public Member Functions | |
| SimpleTransaction () | |
| Construct a SimpleTransaction in its initial idle state. | |
| void | transactionStart () |
| Open a transaction: the processes added until the matching transactionEnd() are reported as one operation. | |
| void | transactionAdd (Enums::PROCESS process) |
Note that process has been queued. | |
| void | transactionEnd (Enums::PROCESS process) |
| Close the transaction opened by the matching transactionStart(). | |
| auto | transactionIsOver (Enums::PROCESS current) -> Enums::PROCESS |
| Tell whether the process that just finished ends the oldest pending transaction, and take that transaction off the queue if so. | |
Private Attributes | |
| int | transactionDepth {0} |
| How many transactionStart() calls are still open. | |
| Enums::PROCESS | lastInTransaction {Enums::INVALID} |
| The process most recently added to the open transaction, or Enums::INVALID when none was added yet. | |
| std::queue< std::pair< Enums::PROCESS, Enums::PROCESS > > | transactionQueue |
| Closed transactions awaiting completion, oldest first: the process that ends each one, and the result to report when it does. | |
Tracks a sequence of processes that should be treated as one atomic operation.
ImitatePass queues several processes for one operation (gpg, then git add, then git commit for an insert) and wants to report the operation once, when the last of them ends. Between transactionStart() and transactionEnd() it calls transactionAdd() for each process it queues; transactionEnd() names the result to report. As processes finish, transactionIsOver() answers with that result for the last one of a transaction and with Enums::INVALID for every earlier one. Transactions may nest; only the outermost one counts.
Definition at line 29 of file simpletransaction.h.
|
inline |
Construct a SimpleTransaction in its initial idle state.
Definition at line 47 of file simpletransaction.h.
| void SimpleTransaction::transactionAdd | ( | Enums::PROCESS | process | ) |
Note that process has been queued.
Inside an open transaction it becomes the transaction's latest step. Outside one it is a transaction of its own, reported as itself.
| process | The process just queued. |
Definition at line 21 of file simpletransaction.cpp.
| void SimpleTransaction::transactionEnd | ( | Enums::PROCESS | process | ) |
Close the transaction opened by the matching transactionStart().
When the outermost transaction closes and at least one process was added, the last one added becomes the step that completes it.
| process | What transactionIsOver() reports once that step ends. |
Definition at line 30 of file simpletransaction.cpp.
| auto SimpleTransaction::transactionIsOver | ( | Enums::PROCESS | current | ) | -> Enums::PROCESS |
Tell whether the process that just finished ends the oldest pending transaction, and take that transaction off the queue if so.
| current | The process that just finished. |
Definition at line 41 of file simpletransaction.cpp.
| void SimpleTransaction::transactionStart | ( | ) |
Open a transaction: the processes added until the matching transactionEnd() are reported as one operation.
Definition at line 16 of file simpletransaction.cpp.
|
private |
The process most recently added to the open transaction, or Enums::INVALID when none was added yet.
Definition at line 36 of file simpletransaction.h.
|
private |
How many transactionStart() calls are still open.
Definition at line 31 of file simpletransaction.h.
|
private |
Closed transactions awaiting completion, oldest first: the process that ends each one, and the result to report when it does.
Definition at line 41 of file simpletransaction.h.