On this page
  1. atomic_load
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

atomic_load

Prev: stdatomic.h | Up: stdatomic.h | Next: atomic_fetch_add
Rel: stdatomic.h, Synchronization & Coordination
Ref: cppreference — atomic_load
Tags: #public #prog #c #stdlib #stdatomic #tier/specialized


Include

#include <stdatomic.h>

Signature & Overview

T atomic_load(const volatile A *obj);  /* also atomic_store */

Atomically reads (or writes via atomic_store) an _Atomic variable with sequential consistency by default.

Notes & Pitfalls

Example

#include <assert.h>
#include <stdatomic.h>

int main(void) {
    atomic_int ready = 1;
    assert(atomic_load(&ready) == 1);
}

Linked from

Related notes