atomic_is_lock_free
atomic_store
atomic_store_explicit
atomic_load atomic_load_explicit
atomic_exchange
atomic_exchange_explicit
atomic_compare_exchange_weak
atomic_compare_exchange_weak_explicit
atomic_compare_exchange_strong
atomic_compare_exchange_strong_explicit
atomic_fetch_add
atomic_fetch_add_explicit
atomic_fetch_sub
atomic_fetch_sub_explicit
atomic_fetch_and
atomic_fetch_and_explicit
atomic_fetch_or
atomic_fetch_or_explicit
atomic_fetch_xor
atomic_fetch_xor_explicit
Here is an example:
#include <atomic>
#include <iostream>
int main()
{
std::atomic<int> i = ATOMIC_VAR_INIT(0);
std::atomic_fetch_add(&i, 1);
std::cout << i << " ";
std::atomic_fetch_sub(&i, 4);
std::cout << i << " ";
std::cout << std::endl;
return 0;
}
// Output: 1 -3
Reference: http://en.cppreference.com/w/cpp/atomic
No comments:
Post a Comment