103
• TX_STAGE_ONABORT: The transaction start either failed or was aborted.
• TX_STAGE_FINALLY: Ready for cleanup.
The example in Listing 7-7 uses the two mandatory stages: TX_BEGIN and TX_END.
However, we could easily have added the other stages to perform actions for the other
stages, for example:
TX_BEGIN(Pop) {
/* the actual transaction code goes here... */
} TX_ONCOMMIT {
/*
* optional - executed only if the above block
* successfully completes
*/
} TX_ONABORT {
/*
* optional - executed only if starting the transaction
* fails, or if transaction is aborted by an error or a
* call to pmemobj_tx_abort()
*/
} TX_FINALLY {
/*
* optional - if exists, it is executed after
* TX_ONCOMMIT or TX_ONABORT block
*/
} TX_END /* mandatory */
Optionally, you can provide a list of parameters for the transaction. Each parameter
consists of a type followed by one of these type-specific number of values:
• TX_PARAM_NONE is used as a termination marker with no following
value.
• TX_PARAM_MUTEX is followed by one value, a pmem-resident
PMEMmutex.
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
• TX_STAGE_ONABORT: The transaction start either failed or was aborted.
• TX_STAGE_FINALLY: Ready for cleanup.
The example in Listing 7-7 uses the two mandatory stages: TX_BEGIN and TX_END.
However, we could easily have added the other stages to perform actions for the other
stages, for example:
TX_BEGIN(Pop) {
/* the actual transaction code goes here... */
} TX_ONCOMMIT {
/*
* optional - executed only if the above block
* successfully completes
*/
} TX_ONABORT {
/*
* optional - executed only if starting the transaction
* fails, or if transaction is aborted by an error or a
* call to pmemobj_tx_abort()
*/
} TX_FINALLY {
/*
* optional - if exists, it is executed after
* TX_ONCOMMIT or TX_ONABORT block
*/
} TX_END /* mandatory */
Optionally, you can provide a list of parameters for the transaction. Each parameter
consists of a type followed by one of these type-specific number of values:
• TX_PARAM_NONE is used as a termination marker with no following
value.
• TX_PARAM_MUTEX is followed by one value, a pmem-resident
PMEMmutex.
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
