P99
Public Member Functions
atomic_flag Struct Reference

The "minimal" type for which atomic operations must be defined. More...

#include <p99_atomic.h>

Public Member Functions

void atomic_flag_clear (volatile atomic_flag *p00_objp)
 Unconditionally set *p00_objp to false.
void atomic_flag_clear_explicit (volatile atomic_flag *p00_objp, memory_order p00_ord)
 Unconditionally set *p00_objp to false.
#define ATOMIC_FLAG_INIT   P99_ENC_INIT(0)
 Initialize a variable of type atomic_flag.
void atomic_flag_lock (volatile atomic_flag *p00_objp)
 extension: spin on p00_objp setting the flag until the state before was "clear"
_Bool atomic_flag_test_and_set (volatile atomic_flag *p00_objp)
 Unconditionally set *object to true and return the previous value.
_Bool atomic_flag_test_and_set_explicit (volatile atomic_flag *p00_objp, memory_order p00_ord)
 Unconditionally set *object to true and return the previous value.
_Bool atomic_flag_trylock (volatile atomic_flag *p00_objp)
 extension: set the flag and return true if we are the first to do so
void atomic_flag_unlock (volatile atomic_flag *p00_objp)
 extension: clear the flag unconditionally

Detailed Description

The "minimal" type for which atomic operations must be defined.

This only has very basic operations that can set and clear the flag. In particular it has no operation that returns the state of the flag and that would not modify it eventually. So this is a kind of Heisenberg flag, you can't measure it without modifying it. This can be used as a spinlock to force the flag to be set, perform a desired operation and then clear the flag, again.

There are extensions atomic_flag_lock, atomic_flag_trylock and atomic_flag_unlock that perform these spinlock type operations with only the necessary memory consistency.

Remarks:
encapsulates an object of type uint32_t volatile
See also:
P99_ENC for access through object
P99_ENCP for access through pointer

Definition at line 513 of file p99_atomic.h.


The documentation for this struct was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines