Zero  0.1.0
Public Member Functions | Private Attributes | List of all members
sys_xct_section_t Class Reference

Used to automatically begin/commit/abort a system transaction. More...

#include <xct.h>

Public Member Functions

 sys_xct_section_t (bool single_log_sys_xct=false)
 
 ~sys_xct_section_t ()
 
rc_t check_error_on_start () const
 
rc_t end_sys_xct (rc_t result)
 

Private Attributes

rc_t _error_on_start
 
size_t _original_xct_depth
 

Detailed Description

Used to automatically begin/commit/abort a system transaction.

Use this class as follows:

rc_t some_function ()
{
  // the function to use system transaction
  sys_xct_section_t sxs;
  W_DO (sxs.check_error_on_start()); // optional: check the system xct successfully started
  rc_t result = do_some_thing();
  W_DO (sxs.end_sys_xct (result)); //commit or abort, depending on the result code
  // if we exit this function without calling end_sys_xct(), the system transaction
  // automatically aborts.
  return result;
}

Constructor & Destructor Documentation

§ sys_xct_section_t()

sys_xct_section_t::sys_xct_section_t ( bool  single_log_sys_xct = false)

starts a nested system transaction.

Parameters
[in]single_log_sys_xctwhether this transaction will have at most one xlog entry

§ ~sys_xct_section_t()

sys_xct_section_t::~sys_xct_section_t ( )

This destructor makes sure the system transaction ended.

Member Function Documentation

§ check_error_on_start()

rc_t sys_xct_section_t::check_error_on_start ( ) const
inline

Tells if any error happened to begin a system transaction in constructor.

§ end_sys_xct()

rc_t sys_xct_section_t::end_sys_xct ( rc_t  result)

Commits or aborts the system transaction, depending on the given result code.

Member Data Documentation

§ _error_on_start

rc_t sys_xct_section_t::_error_on_start
private

§ _original_xct_depth

size_t sys_xct_section_t::_original_xct_depth
private

The documentation for this class was generated from the following files: