atomic_store(), atomic_store_explicit()

Atomically set the value of an atomic object (C11)

Synopsis:

#include <stdatomic.h>

void atomic_store( volatile A *obj,
                  C desired );

void atomic_store_explicit( volatile A *obj,
                            C desired,
                            memory_order order );

Arguments:

obj
A pointer to the atomic object (see the atomic_* types) whose value you want to set.
desired
The value for the object. The “C” represents the non-atomic data type that corresponds to the atomic object.
order
(atomic_store_explicit() only) The memory_order to use for the operation. This must be memory_order_relaxed, memory_order_release, or memory_order_seq_cst.

Library:

Description:

The atomic_store() and atomic_store_explicit() functions are generic functions that atomically set the given atomic object to the given value. The atomic_store() function orders memory access according to memory_order_seq_cst; atomic_store_explicit() orders them as specified by order.

Classification:

C11

Safety:  
Cancellation point No
Interrupt handler Read the Caveats
Signal handler Read the Caveats
Thread Yes

Caveats:

If this function is lock-free (see atomic_is_lock_free()), it's safe to call it from an ISR or signal handler.