GATE
|
Atomic integer and pointer operations. More...
Data Structures | |
struct | gate_atomic_flag_class |
atomic flag storage type More... | |
struct | gate_atomic_lock_class |
atomic lock storage (generic, non-recursive) type More... | |
struct | gate_atomic_rlock_t |
atomic recursive lock storage type More... | |
Typedefs | |
typedef struct gate_atomic_flag_class | gate_atomic_flag_t |
atomic flag storage type | |
typedef gate_int32_t volatile | gate_atomic_int_t |
atomic integer storage type | |
typedef gate_int64_t volatile | gate_atomic_int64_t |
atomic 64-bit integer storage type | |
typedef void *volatile | gate_atomic_ptr_t |
atomic pointer storage type | |
typedef struct gate_atomic_lock_class | gate_atomic_lock_t |
atomic lock storage (generic, non-recursive) type | |
Functions | |
GATE_CORE_API gate_bool_t | gate_atomic_flag_set (gate_atomic_flag_t *atom) |
Sets an atomic flag to true and returns it previous state. | |
GATE_CORE_API void | gate_atomic_flag_clear (gate_atomic_flag_t *atom) |
Sets an atomic flag to false. | |
GATE_CORE_API void | gate_atomic_int_init (gate_atomic_int_t *atom, gate_int32_t value) |
Initializes an uninitialized atomic integer with a specific numeric value. | |
GATE_CORE_API gate_int32_t | gate_atomic_int_set (gate_atomic_int_t *atom, gate_int32_t value) |
Sets an atomic integer to a new value and returns its previous value. | |
GATE_CORE_API gate_int32_t | gate_atomic_int_get (gate_atomic_int_t *atom) |
Returns the current atomic integer value. | |
GATE_CORE_API gate_int32_t | gate_atomic_int_inc (gate_atomic_int_t *atom) |
Increments an atomic integer value by 1. | |
GATE_CORE_API gate_int32_t | gate_atomic_int_dec (gate_atomic_int_t *atom) |
Decrements an atomic integer value by 1. | |
GATE_CORE_API gate_int32_t | gate_atomic_int_add (gate_atomic_int_t *atom, gate_int32_t value) |
Adds a value to an atomic integer. | |
GATE_CORE_API gate_int32_t | gate_atomic_int_xchg_if (gate_atomic_int_t *atom, gate_int32_t comparand, gate_int32_t xchgvalue) |
Set an atomic integer to a new value, if the current value equals a specific value. | |
GATE_CORE_API gate_bool_t | gate_atomic_int_update_if (gate_atomic_int_t *atom, gate_int32_t fromvalue, gate_int32_t tovalue) |
Updates an atomic integer to a new value, if the current value equals a specific value. | |
GATE_CORE_API void | gate_atomic_int64_init (gate_atomic_int64_t *atom, gate_int64_t value) |
Initializes an uninitialized atomic 64bit integer with a specific numeric value. | |
GATE_CORE_API gate_int64_t | gate_atomic_int64_set (gate_atomic_int64_t *atom, gate_int64_t value) |
Sets an atomic 64bit integer to a new value and returns its previous value. | |
GATE_CORE_API gate_int64_t | gate_atomic_int64_get (gate_atomic_int64_t *atom) |
Returns the current atomic 64bit integer value. | |
GATE_CORE_API gate_int64_t | gate_atomic_int64_inc (gate_atomic_int64_t *atom) |
Increments an atomic 64bit integer value by 1. | |
GATE_CORE_API gate_int64_t | gate_atomic_int64_dec (gate_atomic_int64_t *atom) |
Decrements an atomic 64bit integer value by 1. | |
GATE_CORE_API gate_int64_t | gate_atomic_int64_add (gate_atomic_int64_t *atom, gate_int64_t value) |
Adds a value to an atomic 64bit integer. | |
GATE_CORE_API gate_int64_t | gate_atomic_int64_xchg_if (gate_atomic_int64_t *atom, gate_int64_t comparand, gate_int64_t xchgvalue) |
Set an atomic 64bit integer to a new value, if the current value equals a specific value. | |
GATE_CORE_API void | gate_atomic_ptr_init (gate_atomic_ptr_t *atom, void *value) |
Initializes an uninitialized atomic pointer with a specific address. | |
GATE_CORE_API void * | gate_atomic_ptr_set (gate_atomic_ptr_t *atom, void *value) |
Sets an atomic pointer to a new address and returns its previous address. | |
GATE_CORE_API void * | gate_atomic_ptr_get (gate_atomic_ptr_t *atom) |
Returns the current atomic pointer address. | |
GATE_CORE_API void * | gate_atomic_ptr_xchg_if (gate_atomic_ptr_t *atom, void *comparand, void *xchgvalue) |
Set an atomic pointer to a new address, if the current address equals a specific address. | |
GATE_CORE_API void | gate_atomic_lock_acquire (gate_atomic_lock_t *atom) |
Aquires an atomic lock by spinning until it is available. | |
GATE_CORE_API gate_bool_t | gate_atomic_lock_acquire_spin (gate_atomic_lock_t *atom, gate_uint32_t spincount) |
Tries to acquire an atomic lock within a spin-limit. | |
GATE_CORE_API void | gate_atomic_lock_release (gate_atomic_lock_t *atom) |
Releases an owned atomic lock. | |
GATE_CORE_API void | gate_atomic_rlock_acquire (gate_atomic_rlock_t *atom) |
Aquires an atomic recursive lock by spinning until it is available. | |
GATE_CORE_API gate_bool_t | gate_atomic_rlock_acquire_spin (gate_atomic_rlock_t *atom, gate_uint32_t spincount) |
Tries to acquire an atomic recursive lock within a spin-limit. | |
GATE_CORE_API void | gate_atomic_rlock_release (gate_atomic_rlock_t *atom) |
Releases an owned atomic recursive lock. | |
GATE_CORE_API void | gate_atomic_call_once (gate_atomic_flag_t *ptr_once_flag, void(*func)(void)) |
Runs a given function only the first time it is invoked. | |
GATE_CORE_API void | gate_atomic_call_once_exclusive (gate_atomic_flag_t *ptr_once_flag, void(*func)(void)) |
Runs a given function only the first time it is invoked and exclusively locks the function call. | |
Atomic integer and pointer operations.
GATE_CORE_API gate_bool_t gate_atomic_flag_set | ( | gate_atomic_flag_t * | atom | ) |
Sets an atomic flag to true and returns it previous state.
[in,out] | atom | Pointer to atomic flag stoarge |
GATE_CORE_API void gate_atomic_flag_clear | ( | gate_atomic_flag_t * | atom | ) |
Sets an atomic flag to false.
[in,out] | atom | Pointer to atomic flag stoarge |
GATE_CORE_API void gate_atomic_int_init | ( | gate_atomic_int_t * | atom, |
gate_int32_t | value ) |
Initializes an uninitialized atomic integer with a specific numeric value.
[out] | atom | Pointer to atomic integer storage |
[in] | value | new value of atomic integer |
GATE_CORE_API gate_int32_t gate_atomic_int_set | ( | gate_atomic_int_t * | atom, |
gate_int32_t | value ) |
Sets an atomic integer to a new value and returns its previous value.
[in,out] | atom | Pointer to atomic integer storage |
[in] | value | New value of atomic integer |
GATE_CORE_API gate_int32_t gate_atomic_int_get | ( | gate_atomic_int_t * | atom | ) |
Returns the current atomic integer value.
[in,out] | atom | Pointer to atomic integer storage |
GATE_CORE_API gate_int32_t gate_atomic_int_inc | ( | gate_atomic_int_t * | atom | ) |
Increments an atomic integer value by 1.
[in,out] | atom | Pointer to atomic integer storage |
GATE_CORE_API gate_int32_t gate_atomic_int_dec | ( | gate_atomic_int_t * | atom | ) |
Decrements an atomic integer value by 1.
[in,out] | atom | Pointer to atomic integer storage |
GATE_CORE_API gate_int32_t gate_atomic_int_add | ( | gate_atomic_int_t * | atom, |
gate_int32_t | value ) |
Adds a value to an atomic integer.
[in,out] | atom | Pointer to atomic integer storage |
[in] | value | Value to be added (or subtracted if negative) |
GATE_CORE_API gate_int32_t gate_atomic_int_xchg_if | ( | gate_atomic_int_t * | atom, |
gate_int32_t | comparand, | ||
gate_int32_t | xchgvalue ) |
Set an atomic integer to a new value, if the current value equals a specific value.
[in,out] | atom | Pointer to atomic integer storage |
[in] | comparand | Value to be compared to atomic integer, if unequal no update is applied |
[in] | xchgvalue | Value to be applied, if 'comparand' equals the current value |
GATE_CORE_API gate_bool_t gate_atomic_int_update_if | ( | gate_atomic_int_t * | atom, |
gate_int32_t | fromvalue, | ||
gate_int32_t | tovalue ) |
Updates an atomic integer to a new value, if the current value equals a specific value.
[in,out] | atom | Pointer to atomic integer storage |
[in] | fromvalue | Value to be compared to atomic integer, if unequal no update is applied |
[in] | tovalue | Value to be applied, if 'comparand' equals the current value |
GATE_CORE_API void gate_atomic_int64_init | ( | gate_atomic_int64_t * | atom, |
gate_int64_t | value ) |
Initializes an uninitialized atomic 64bit integer with a specific numeric value.
[out] | atom | Pointer to atomic 64bit integer storage |
[in] | value | new value of atomic 64bit integer |
GATE_CORE_API gate_int64_t gate_atomic_int64_set | ( | gate_atomic_int64_t * | atom, |
gate_int64_t | value ) |
Sets an atomic 64bit integer to a new value and returns its previous value.
[in,out] | atom | Pointer to atomic 64bit integer storage |
[in] | value | new value of atomic 64bit integer |
GATE_CORE_API gate_int64_t gate_atomic_int64_get | ( | gate_atomic_int64_t * | atom | ) |
Returns the current atomic 64bit integer value.
[in,out] | atom | Pointer to atomic 64bit integer storage |
GATE_CORE_API gate_int64_t gate_atomic_int64_inc | ( | gate_atomic_int64_t * | atom | ) |
Increments an atomic 64bit integer value by 1.
[in,out] | atom | Pointer to atomic 64bit integer storage |
GATE_CORE_API gate_int64_t gate_atomic_int64_dec | ( | gate_atomic_int64_t * | atom | ) |
Decrements an atomic 64bit integer value by 1.
[in,out] | atom | Pointer to atomic 64bit integer storage |
GATE_CORE_API gate_int64_t gate_atomic_int64_add | ( | gate_atomic_int64_t * | atom, |
gate_int64_t | value ) |
Adds a value to an atomic 64bit integer.
[in,out] | atom | Pointer to atomic 64bit integer storage |
[in] | value | Value to be added (or subtracted if negative) |
GATE_CORE_API gate_int64_t gate_atomic_int64_xchg_if | ( | gate_atomic_int64_t * | atom, |
gate_int64_t | comparand, | ||
gate_int64_t | xchgvalue ) |
Set an atomic 64bit integer to a new value, if the current value equals a specific value.
[in,out] | atom | Pointer to atomic 64bit integer storage |
[in] | comparand | Value to be compared to atomic 64bit integer, if unequal no update is applied |
[in] | xchgvalue | Value to be applied, if 'comparand' equals the current value |
GATE_CORE_API void gate_atomic_ptr_init | ( | gate_atomic_ptr_t * | atom, |
void * | value ) |
Initializes an uninitialized atomic pointer with a specific address.
[out] | atom | Pointer to atomic pointer storage |
[in] | value | new address of atomic pointer |
GATE_CORE_API void * gate_atomic_ptr_set | ( | gate_atomic_ptr_t * | atom, |
void * | value ) |
Sets an atomic pointer to a new address and returns its previous address.
[in,out] | atom | Pointer to atomic pointer storage |
[in] | value | new address of atomic pointer |
GATE_CORE_API void * gate_atomic_ptr_get | ( | gate_atomic_ptr_t * | atom | ) |
Returns the current atomic pointer address.
[in,out] | atom | Pointer to atomic pointer storage |
GATE_CORE_API void * gate_atomic_ptr_xchg_if | ( | gate_atomic_ptr_t * | atom, |
void * | comparand, | ||
void * | xchgvalue ) |
Set an atomic pointer to a new address, if the current address equals a specific address.
[in,out] | atom | Pointer to atomic pointer storage |
[in] | comparand | Address to be compared to atomic pointer, if unequal no update is applied |
[in] | xchgvalue | Address to be applied, if 'comparand' equals the current address |
GATE_CORE_API void gate_atomic_lock_acquire | ( | gate_atomic_lock_t * | atom | ) |
Aquires an atomic lock by spinning until it is available.
[in,out] | atom | Pointer to atomic lock storage |
GATE_CORE_API gate_bool_t gate_atomic_lock_acquire_spin | ( | gate_atomic_lock_t * | atom, |
gate_uint32_t | spincount ) |
Tries to acquire an atomic lock within a spin-limit.
[in,out] | atom | Pointer to atomic lock storage |
[in] | spincount | Count of lock aquire attempts |
GATE_CORE_API void gate_atomic_lock_release | ( | gate_atomic_lock_t * | atom | ) |
Releases an owned atomic lock.
[in,out] | atom | Pointer to atomic lock storage |
GATE_CORE_API void gate_atomic_rlock_acquire | ( | gate_atomic_rlock_t * | atom | ) |
Aquires an atomic recursive lock by spinning until it is available.
[in,out] | atom | Pointer to atomic recursive lock storage |
GATE_CORE_API gate_bool_t gate_atomic_rlock_acquire_spin | ( | gate_atomic_rlock_t * | atom, |
gate_uint32_t | spincount ) |
Tries to acquire an atomic recursive lock within a spin-limit.
[in,out] | atom | Pointer to atomic recursive lock storage |
[in] | spincount | Maximum count of lock aquire attempts |
GATE_CORE_API void gate_atomic_rlock_release | ( | gate_atomic_rlock_t * | atom | ) |
Releases an owned atomic recursive lock.
[in,out] | atom | Pointer to atomic recursive lock storage |
GATE_CORE_API void gate_atomic_call_once | ( | gate_atomic_flag_t * | ptr_once_flag, |
void(* | func )(void) ) |
Runs a given function only the first time it is invoked.
[in,out] | ptr_once_flag | Pointer to flag variable that stores the state |
[in] | func | Function to be called |
GATE_CORE_API void gate_atomic_call_once_exclusive | ( | gate_atomic_flag_t * | ptr_once_flag, |
void(* | func )(void) ) |
Runs a given function only the first time it is invoked and exclusively locks the function call.
[in,out] | ptr_once_flag | Pointer to flag variable that stores the state |
[in] | func | Function to be called |