std1.0.0-beta-7 SafeC docs

std :: atomic

Struct std::AtomicInt

#include <std/atomic.h> source

struct AtomicInt { }

An int / long long every access to which is atomic: Sync, so threads may share one through a mutable reference ('&static AtomicInt', or a local lent to spawn_scoped threads) where a plain int would race. static struct AtomicInt hits; // zero-initialized hits.fetch_add(1);

Methods

§static struct AtomicInt new(int v)source · definition
§int load() constsource · definition
§void store(int v)source · definition
§int fetch_add(int d)source · definition

returns the old value

§int fetch_sub(int d)source · definition
§int exchange(int v)source · definition
§int compare_exchange(&int expected, int desired)source · definition

1 if stored