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
returns the old value
1 if stored