std::atomic<T>::is_lock_free (3) - Linux Manuals
std::atomic<T>::is_lock_free: std::atomic<T>::is_lock_free
NAME
std::atomic<T>::is_lock_free - std::atomic<T>::is_lock_free
Synopsis
bool is_lock_free() const noexcept; (since C++11)
bool is_lock_free() const volatile noexcept;
Checks whether the atomic operations on all objects of this type are lock-free.
Parameters
(none)
Return value
true if the atomic operations on the objects of this type are lock-free, false otherwise.
Notes
All atomic types except for std::atomic_flag may be implemented using mutexes or other locking operations, rather than using the lock-free atomic CPU instructions. Atomic types are also allowed to be sometimes lock-free, e.g. if only aligned memory accesses are naturally atomic on a given architecture, misaligned objects of the same type have to use locks.
The C++ standard recommends (but does not require) that lock-free atomic operations are also address-free, that is, suitable for communication between processes using shared memory.
Example
// Run this code
Possible output:
See also
atomic_is_lock_free checks if the atomic type's operations are lock-free
(C++11)
atomic_is_lock_free(std::shared_ptr) (function template)
is_always_lock_free indicates that the type is always lock-free
[static] (C++17)