|
|
The TransactionManager creates, manages, and dispatches transactions. A Transaction is comprised of a sequence of TransactionOperation s. Each transaction is uniquely identified by a transaction id.
typedef ref_ptr<TransactionOperation> Operation | Operation |
TransactionManager (EventLoop& e,
uint32_t timeout_ms = 0,
uint32_t max_pending = 10)
| TransactionManager |
Constuctor with a given event loop, timeout, and max pending commits.
Parameters:
e | the EventLoop instance. |
timeout_ms | the inter-operation addition timeout. If zero, timeouts are not used, otherwise a timeout will occur and the transaction aborted if the transaction is not updated for timeout_ms. |
max_pending | the maximum number of uncommitted transactions pending commit. |
~TransactionManager ()
| ~TransactionManager |
[virtual]
bool start (uint32_t& new_tid)
| start |
Start transaction
Parameters:
new_tid | variable to assigned new transaction id. |
Returns: true on success, false if maximum number of pending transactions is reached.
bool commit (uint32_t tid)
| commit |
Commit transaction
Parameters:
tid | the transaction ID. |
Returns: true on success, false on error.
bool abort (uint32_t tid)
| abort |
Abort transaction
Parameters:
tid | the transaction ID. |
Returns: true on success, false on error.
bool add (uint32_t tid, const Operation& op)
| add |
[virtual]
Add operation to transaction.
Parameters:
tid | the transaction ID. |
operation | to be added. |
Returns: true on success, false if tid is invalid.
bool retrieve_size (uint32_t tid, uint32_t& count)
| retrieve_size |
[const]
Retrieve number of operations in pending transaction.
Parameters:
tid | the transaction ID. |
count | variable to be assigned number of operations in transaction. |
Returns: true if tid is valid, false otherwise.
uint32_t timeout_ms ()
| timeout_ms |
[const]
Get the inter-operation additional timeout.
If the inter-operation addition timeout is zero, timeouts are not used, otherwise a timeout will occur and the transaction aborted if the transaction is not updated for timeout_ms.
Returns: the inter-operation additional timeout.
uint32_t max_pending ()
| max_pending |
[const]
Get the maximum number of uncommited pending transactions.
Returns: the maximum number of uncommitted transactions pending commit.
uint32_t pending ()
| pending |
[const]
Get the current number of uncommited pending transactions.
Returns: the current number of uncommitted transactions pending commit.
void pre_commit (uint32_t tid)
| pre_commit |
[protected virtual]
Overrideable function that can be called before the first operation in a commit is dispatched.
Default implementation is a no-op.
void post_commit (uint32_t tid)
| post_commit |
[protected virtual]
Overrideable function that can be called after commit occurs
Default implementation is a no-op.
void operation_result (bool success,
const TransactionOperation& op)
| operation_result |
[protected virtual]
Overrideable function that is called immediately after an individual operation is dispatched.
Default implementation is a no-op.
Parameters:
success | whether the operation succeed. |
op | the operation. |
bool flush (uint32_t tid)
| flush |
[protected]
Flush operations in transaction list. May be use by operation_result methods to safely prevent further operations being dispatched when errors are detected. flush() always succeeds if transaction exists.
Parameters:
tid | transaction id of transaction to be flushed. |
Returns: true if transaction exists, false otherwise.
Transaction (struct) | Transaction |
[protected]
Transaction class, just a list of operations to be dispatched.
It is defined here so classes derived from TransactionManager can operate, eg sort operations in list, before committing transaction.