src/core/tx.h

Go to the documentation of this file.
00001 
00007 #ifndef _TX_H
00008 #define _TX_H
00009 
00010 #include <core/buffer.h>
00011 #include <core/sentinel.h>
00012 
00013 /* 
00014  * This opaque type is defined here. 
00015  * To resolve any circular dependencies between tx.h and other header files,
00016  * allow other header files to define this opaque type and define it if others
00017  * have not done so.  
00018  */
00019 # ifndef TYPEDEF_TXC_TX_T
00020 # define TYPEDEF_TXC_TX_T
00021 typedef struct txc_tx_s txc_tx_t;
00022 # endif /* TYPEDEF_TXC_TX_T */
00023 
00024 typedef struct txc_txmgr_s txc_txmgr_t;
00025 
00026 typedef void (*txc_tx_function_t)(void *, int *);
00027 typedef void (*txc_tx_undo_function_t)(void *, int *);
00028 typedef void (*txc_tx_commit_function_t)(void *, int *);
00029 
00030 
00031 /* This type is also exported to users of the library via txc.h 
00032  * Must keep it in sync.
00033  */
00034 # ifndef TYPEDEF_TXC_TX_ABORTREASON_T
00035 # define TYPEDEF_TXC_TX_ABORTREASON_T
00036 typedef enum {
00037         TXC_ABORTREASON_TMCONFLICT = 0, 
00038     TXC_ABORTREASON_USERABORT = 1, 
00039         TXC_ABORTREASON_USERRETRY = 2, 
00040         TXC_ABORTREASON_BUSYSENTINEL = 4, 
00041         TXC_ABORTREASON_INCONSISTENCY = 8, 
00042         TXC_ABORTREASON_BUSYTXLOCK = 16, 
00043 } txc_tx_abortreason_t;
00044 # endif /* TYPEDEF_TXC_TX_ABORT_REASON_T */
00045 
00046 
00047 /* This type is also exported to users of the library via txc.h 
00048  * Must keep it in sync.
00049  */
00050 # ifndef TYPEDEF_TXC_TX_XACTSTATE_T
00051 # define TYPEDEF_TXC_TX_XACTSTATE_T
00052 typedef enum {
00053         TXC_XACTSTATE_NONTRANSACTIONAL = 0, 
00054     TXC_XACTSTATE_TRANSACTIONAL_RETRYABLE = 1, 
00055         TXC_XACTSTATE_TRANSACTIONAL_IRREVOCABLE = 2
00056 } txc_tx_xactstate_t;
00057 # endif /* TYPEDEF_TXC_TX_XACTSTATE_T */
00058 
00059 
00060 typedef struct txc_tx_srcloc_s txc_tx_srcloc_t;
00061 
00062 struct txc_tx_srcloc_s {
00063         const char *file;
00064         const char *fun;
00065         int  line;
00066 };
00067 
00068 
00069 extern txc_txmgr_t *txc_g_txmgr;
00070 extern __thread txc_tx_t *txc_l_txd;
00071 
00072 int txc_tx_xact_state_get();
00073 
00074 #include <core/stats.h>
00075 
00076 txc_result_t txc_txmgr_create(txc_txmgr_t **, txc_buffermgr_t *, txc_sentinelmgr_t *, txc_statsmgr_t *statsmgr);
00077 txc_result_t txc_txmgr_destroy(txc_txmgr_t **);
00078 txc_result_t txc_tx_create(txc_txmgr_t *, txc_tx_t **);
00079 txc_result_t txc_tx_destroy(txc_tx_t **);
00080 void txc_tx_abort_transaction(txc_tx_t *, txc_tx_abortreason_t);
00081 txc_result_t txc_tx_register_commit_action(txc_tx_t *, txc_tx_commit_function_t, void *, int *, int); 
00082 txc_result_t txc_tx_register_undo_action(txc_tx_t *, txc_tx_undo_function_t, void *, int *, int);
00083 txc_tx_t *txc_tx_get_txd();   
00084 unsigned int txc_tx_get_tid(txc_tx_t *txd);
00085 unsigned int txc_tx_get_tid_pthread(txc_tx_t *txd);
00086 txc_tx_xactstate_t txc_tx_get_xactstate(txc_tx_t *txd); 
00087 unsigned int txc_tx_get_forced_retries(txc_tx_t *txd);
00088 void txc_tx_pre_begin(txc_tx_t *txd, const char *srcloc_str, txc_tx_srcloc_t *srcloc);
00089 void txc_tx_post_begin(txc_tx_t *txd);
00090 
00091 void txc_txmgr_print(txc_txmgr_t *);
00092 txc_result_t txc_tx_exists(txc_txmgr_t *, txc_tx_t *);
00093 
00094 #endif    /* _TX_H */

Generated on Wed Dec 9 20:32:39 2009 for xCalls by  doxygen 1.4.7