std::atomic_is_lock_free, ATOMIC_xxx_LOCK_FREE - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::atomic_is_lock_free, ATOMIC_xxx_LOCK_FREE

From cppreference.com
< cpp‎ | atomic

Defined in header `<atomic>` |  |
| (1) | (since C++11)
template< class T > bool atomic_is_lock_free( const volatile std::atomic<T>* obj ); |  |
template< class T > bool atomic_is_lock_free( const std::atomic<T>* obj ); |  |
#define ATOMIC_BOOL_LOCK_FREE /* unspecified */ #define ATOMIC_CHAR_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_SHORT_LOCK_FREE /* unspecified */ #define ATOMIC_INT_LOCK_FREE /* unspecified */ #define ATOMIC_LONG_LOCK_FREE /* unspecified */ #define ATOMIC_LLONG_LOCK_FREE /* unspecified */ #define ATOMIC_POINTER_LOCK_FREE /* unspecified */ | (2) | (since C++11)

1) Determines if the atomic object pointed to by `obj` is implemented lock-free, as if by calling obj->is_lock_free(). In any given program execution, the result of the lock-free query is the same for all pointers of the same type.
2) Expands to an integer constant expression with value

- ​0​ for the built-in atomic types that are never lock-free
- 1 for the built-in atomic types that are sometimes lock-free
- 2 for the built-in atomic types that are always lock-free.

### [edit] Parameters

obj | - | pointer to the atomic object to examine

### [edit] Return value

true if *obj is a lock-free atomic, false otherwise.

### [edit] Exceptions

`noexcept` specification:
noexcept

### [edit] 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.

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

is_lock_free | checks if the atomic object is lock-free (public member function of `std::atomic`) [edit]
std::atomic_is_lock_free(std::shared_ptr) | specializes atomic operations for std::shared_ptr (function template)
atomic_flag (C++11) | the lock-free boolean atomic type (class) [edit]
C documentation for atomic_is_lock_free
C documentation for ATOMIC_*_LOCK_FREE

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/atomic/atomic_is_lock_free&oldid=75816"
Categories:

- unconditionally noexcept
- Todo no example