|
xorp
|
A class for managing transactions. More...
#include <transaction.hh>
Classes | |
| class | Transaction |
| Transaction class, just a list of operations to be dispatched. More... | |
Public Types | |
|
typedef ref_ptr < TransactionOperation > | Operation |
Public Member Functions | |
| TransactionManager (EventLoop &e, uint32_t timeout_ms=0, uint32_t max_pending=10) | |
| Constuctor with a given event loop, timeout, and max pending commits. | |
| virtual | ~TransactionManager () |
| Destructor. | |
| bool | start (uint32_t &new_tid) |
| Start transaction. | |
| bool | commit (uint32_t tid) |
| Commit transaction. | |
| bool | abort (uint32_t tid) |
| Abort transaction. | |
| virtual bool | add (uint32_t tid, const Operation &op) |
| Add operation to transaction. | |
| bool | retrieve_size (uint32_t tid, uint32_t &count) const |
| Retrieve number of operations in pending transaction. | |
| uint32_t | timeout_ms () const |
| Get the inter-operation additional timeout. | |
| uint32_t | max_pending () const |
| Get the maximum number of uncommited pending transactions. | |
| uint32_t | pending () const |
| Get the current number of uncommited pending transactions. | |
Protected Member Functions | |
| virtual void | pre_commit (uint32_t tid) |
| Overrideable function that can be called before the first operation in a commit is dispatched. | |
| virtual void | post_commit (uint32_t tid) |
| Overrideable function that can be called after commit occurs. | |
| virtual void | operation_result (bool success, const TransactionOperation &op) |
| Overrideable function that is called immediately after an individual operation is dispatched. | |
| bool | flush (uint32_t tid) |
| Flush operations in transaction list. | |
Private Types | |
|
typedef map< uint32_t, Transaction > | TransactionDB |
Private Member Functions | |
| void | timeout (uint32_t tid) |
| Called when timeout timer expires. | |
| void | crank_tid () |
| Increment next transaction id by a randomized amount. | |
Private Attributes | |
| EventLoop & | _e |
| TransactionDB | _transactions |
| uint32_t | _timeout_ms |
| uint32_t | _max_pending |
| uint32_t | _next_tid |
Friends | |
| class | Transaction |
A class for managing transactions.
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.
| TransactionManager::TransactionManager | ( | EventLoop & | e, |
| uint32_t | timeout_ms = 0, |
||
| uint32_t | max_pending = 10 |
||
| ) | [inline] |
Constuctor with a given event loop, timeout, and max pending commits.
| bool TransactionManager::abort | ( | uint32_t | tid | ) |
| bool TransactionManager::add | ( | uint32_t | tid, |
| const Operation & | op | ||
| ) | [virtual] |
Add operation to transaction.
| tid | the transaction ID. |
| operation | to be added. |
| bool TransactionManager::commit | ( | uint32_t | tid | ) |
| void TransactionManager::crank_tid | ( | ) | [private] |
Increment next transaction id by a randomized amount.
| bool TransactionManager::flush | ( | uint32_t | tid | ) | [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.
| tid | transaction id of transaction to be flushed. |
| uint32_t TransactionManager::max_pending | ( | ) | const [inline] |
| void TransactionManager::operation_result | ( | bool | success, |
| const TransactionOperation & | op | ||
| ) | [protected, virtual] |
Overrideable function that is called immediately after an individual operation is dispatched.
Default implementation is a no-op.
Reimplemented in FibConfigTransactionManager, FirewallTransactionManager, and IfConfigTransactionManager.
| uint32_t TransactionManager::pending | ( | ) | const [inline] |
| void TransactionManager::post_commit | ( | uint32_t | tid | ) | [protected, virtual] |
Overrideable function that can be called after commit occurs.
Default implementation is a no-op.
Reimplemented in FibConfigTransactionManager.
| void TransactionManager::pre_commit | ( | uint32_t | tid | ) | [protected, virtual] |
Overrideable function that can be called before the first operation in a commit is dispatched.
Default implementation is a no-op.
Reimplemented in FibConfigTransactionManager, FirewallTransactionManager, and IfConfigTransactionManager.
| bool TransactionManager::retrieve_size | ( | uint32_t | tid, |
| uint32_t & | count | ||
| ) | const |
Retrieve number of operations in pending transaction.
| tid | the transaction ID. |
| count | variable to be assigned number of operations in transaction. |
| bool TransactionManager::start | ( | uint32_t & | new_tid | ) |
Start transaction.
| new_tid | variable to assigned new transaction id. |
| uint32_t TransactionManager::timeout_ms | ( | ) | const [inline] |