#include <misc/result.h>
Go to the source code of this file.
Definition in file sentinel.h.
#define TXC_SENTINEL_ACQUIRED 0x1 |
Sentinel has been acquired. Drop it when transaction completes (commit/abort) or restarts execution.
Definition at line 13 of file sentinel.h.
#define TXC_SENTINEL_ACQUIREONRETRY 0x2 |
Acquire the sentinel after transaction restarts.
Definition at line 14 of file sentinel.h.
Referenced by txc_sentinel_enlist(), txc_sentinel_tryacquire(), x_close(), x_dup(), x_fsync(), x_lseek(), x_read(), x_rename(), x_sendmsg(), x_unlink(), and x_write_pipe().
void txc_sentinel_destroy | ( | txc_sentinel_t * | sentinel | ) |
Destroys a sentinel.
[in] | sentinel | The sentinel to destroy (deallocate). |
Definition at line 252 of file sentinel.c.
References txc_sentinel_s::synch_mutex, TXC_ASSERT, TXC_MUTEX_LOCK, and TXC_MUTEX_UNLOCK.
txc_result_t txc_sentinel_detach | ( | txc_sentinel_t * | sentinel | ) |
Detaches from a sentinel.
It logically detaches from the sentinel by decrementing the sentinel's refererence counter. If reference counter becomes zero then sentinel is destroyed.
[in] | sentinel | The sentinel to detach from. |
Definition at line 294 of file sentinel.c.
References txc_sentinel_s::synch_mutex, TXC_MUTEX_LOCK, and TXC_MUTEX_UNLOCK.
Referenced by txc_koa_destroy().
txc_result_t txc_sentinel_enlist | ( | txc_tx_t * | txd, | |
txc_sentinel_t * | sentinel, | |||
int | flags | |||
) |
Enlist the sentinel in the transaction's sentinel list.
It also attaches to the sentinel by bumping up the sentinel's refcount via a call to sentinel_attach().
[in] | txd | Transactional descriptor. |
[in] | sentinel | Sentinel to enlist. |
[in] | flags | TXC_SENTINEL_ACQUIREONRETRY |
Definition at line 730 of file sentinel.c.
References txc_tx_s::sentinel_list, txc_sentinel_s::synch_mutex, TXC_MUTEX_LOCK, TXC_MUTEX_UNLOCK, TXC_R_SUCCESS, and TXC_SENTINEL_ACQUIREONRETRY.
txc_result_t txc_sentinel_list_create | ( | txc_sentinelmgr_t * | sentinelmgr, | |
txc_sentinel_list_t ** | sentinel_list | |||
) |
Create a sentinel list.
[in] | sentinelmgr | Sentinel manager responsible for the sentinel list. |
[in,out] | sentinel_list | Pointer to the created sentinel list. |
Definition at line 618 of file sentinel.c.
References FREE, MALLOC, TXC_R_NOMEMORY, TXC_R_SUCCESS, and TXC_SENTINEL_LIST_SIZE.
Referenced by txc_txmgr_create().
txc_result_t txc_sentinel_list_destroy | ( | txc_sentinel_list_t ** | sentinel_list | ) |
Destroy a sentinel list.
Deallocate sentinel list entries and then deallocates the list itself
[in,out] | sentinel_list | Pointer to the sentinel list to deallocate. Pointer will point to NULL after return. |
Definition at line 669 of file sentinel.c.
References FREE, and TXC_R_SUCCESS.
Referenced by txc_txmgr_destroy().
txc_result_t txc_sentinel_list_init | ( | txc_sentinel_list_t * | sentinel_list | ) |
Initialize a sentinel list.
[in] | sentinel_list | Sentinel list to deallocate. |
Definition at line 651 of file sentinel.c.
References txc_sentinel_list_s::num_entries, and TXC_R_SUCCESS.
Referenced by txc_tx_create().
txc_result_t txc_sentinel_tryacquire | ( | txc_tx_t * | txd, | |
txc_sentinel_t * | sentinel, | |||
int | flags | |||
) |
Try to acquire a sentinel.
It will try to acquire the sentinel. If sentinel is acquired it will enlist it in the transaction's sentinel list as acquired, otherwise if the sentinel is not acquired (busy) it will return without block-waiting for the sentinel to become free (prevent deadlock).
[in] | txd | Transactional descriptor. |
[in] | sentinel | Sentinel to acquire. |
[in] | flags | TXC_SENTINEL_ACQUIRED, TXC_SENTINEL_ACQUIREONRETRY |
Definition at line 759 of file sentinel.c.
References txc_sentinel_s::id, txc_sentinel_s::owner, txc_sentinel_s::sentinel_mutex, txc_sentinel_s::synch_mutex, TXC_ASSERT, TXC_DEBUG_PRINT, TXC_INTERNALERROR, TXC_MUTEX_LOCK, TXC_MUTEX_TRYLOCK, TXC_MUTEX_UNLOCK, TXC_R_BUSYSENTINEL, TXC_R_SUCCESS, txc_runtime_settings, TXC_SENTINEL_ACQUIREONRETRY, txc_sentinel_is_enlisted(), txc_sentinel_owner(), and txc_tx_get_xactstate().
Referenced by x_close(), x_create(), x_dup(), x_fsync(), x_lseek(), x_open(), x_pipe(), x_read(), x_rename(), x_sendmsg(), x_socket(), x_unlink(), and x_write_pipe().
txc_result_t txc_sentinelmgr_create | ( | txc_sentinelmgr_t ** | sentinelmgrp | ) |
Creates a sentinel manager.
It preallocates a pool of sentinels to make sentinel allocation fast.
[out] | sentinelmgrp | Pointer to the created sentinel manager. |
Definition at line 158 of file sentinel.c.
References FREE, txc_sentinel_s::id, MALLOC, txc_sentinel_s::manager, txc_sentinel_s::owner, txc_sentinel_s::sentinel_mutex, txc_sentinel_s::synch_mutex, TXC_MUTEX_INIT, txc_pool_create(), TXC_POOL_OBJECT_ALLOCATED, txc_pool_object_first(), TXC_POOL_OBJECT_FREE, txc_pool_object_next(), txc_pool_object_of(), TXC_R_NOMEMORY, TXC_R_SUCCESS, TXC_SENTINEL_NOOWNER, and TXC_SENTINEL_NUM.
Referenced by _TXC_global_init().
void txc_sentinelmgr_destroy | ( | txc_sentinelmgr_t ** | sentinelmgrp | ) |
Destroys a sentinel manager.
It deallocates all sentinels that it manages.
[in,out] | sentinelmgrp | Poitner to the sentinel manager to be destroyed. |
Definition at line 206 of file sentinel.c.
References FREE, and txc_pool_destroy().