Documentation Home >> Headers >> <atomic> Header

The <atomic> header provides the set of basic atomic types and operations on those types, and a class template for constructing an atomic version of a user-defined type that meets certain criteria.

#define ATOMIC_BOOL_LOCK_FREE unspecified
#define ATOMIC_CHAR_LOCK_FREE unspecified
#define ATOMIC_SHORT_LOCK_FREE unspecified
#define ATOMIC_INT_LOCK_FREE unspecified
#define ATOMIC_LONG_LOCK_FREE unspecified
#define ATOMIC_LLONG_LOCK_FREE unspecified
#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
#define ATOMIC_POINTER_LOCK_FREE unspecified

#define ATOMIC_VAR_INIT(value) see description

namespace std
{
    enum memory_order;

    struct atomic_flag;
    typedef unspecified atomic_bool;
    typedef unspecified atomic_char;
    typedef unspecified atomic_char16_t;
    typedef unspecified atomic_char32_t;
    typedef unspecified atomic_schar;
    typedef unspecified atomic_uchar;
    typedef unspecified atomic_short;
    typedef unspecified atomic_ushort;
    typedef unspecified atomic_int;
    typedef unspecified atomic_uint;
    typedef unspecified atomic_long;
    typedef unspecified atomic_ulong;
    typedef unspecified atomic_llong;
    typedef unspecified atomic_ullong;
    typedef unspecified atomic_wchar_t;

    typedef unspecified atomic_int_least8_t;
    typedef unspecified atomic_uint_least8_t;
    typedef unspecified atomic_int_least16_t;
    typedef unspecified atomic_uint_least16_t;
    typedef unspecified atomic_int_least32_t;
    typedef unspecified atomic_uint_least32_t;
    typedef unspecified atomic_int_least64_t;
    typedef unspecified atomic_uint_least64_t;
    typedef unspecified atomic_int_fast8_t;
    typedef unspecified atomic_uint_fast8_t;
    typedef unspecified atomic_int_fast16_t;
    typedef unspecified atomic_uint_fast16_t;
    typedef unspecified atomic_int_fast32_t;
    typedef unspecified atomic_uint_fast32_t;
    typedef unspecified atomic_int_fast64_t;
    typedef unspecified atomic_uint_fast64_t;
    typedef unspecified atomic_intptr_t;
    typedef unspecified atomic_uintptr_t;
    typedef unspecified atomic_size_t;
    typedef unspecified atomic_ptrdiff_t;
    typedef unspecified atomic_intmax_t;
    typedef unspecified atomic_uintmax_t;

    template<typename T>
    struct atomic;

    void atomic_thread_fence(memory_order order);
    void atomic_signal_fence(memory_order order);

    template<typename T>
    T kill_dependency(T);

    // for backwards compatibility only
#define ATOMIC_ADDRESS_LOCK_FREE unspecified
    struct atomic_address;
}
just::thread specific debug support

It is vital that values of atomic type are suitably aligned in memory, otherwise the atomic operations might fail, or be non-atomic in nature. If you use the default settings of your compiler then the just::thread library will ensure this constraint is met. However, if you use compiler pragmas and/or options such as #pragma pack to change the alignment or packing of objects in your code then the library might not be able to guarantee this constraint is met, and you must ensure that the appropriate alignment requirements are upheld.

To assist with identifying problems with alignment, if _JUST_THREAD_ATOMIC_CHECK is defined then atomic operations will assert that the alignment requirements on the corresponding type are met, and abort the program if this is not the case. This is not included by default as it has a performance impact on every atomic operation.

If you define _JUST_THREAD_DEADLOCK_CHECK then this assert is also automatically enabled.

See Also