Difference between revisions of "cpp/atomic/atomic is lock free"
D41D8CD98F (Talk | contribs) m (`ATOMIC_BOOL_LOCK_FREE` was missing) |
D41D8CD98F (Talk | contribs) (see c) |
||
Line 5: | Line 5: | ||
{{dcl rev begin | num=1 | since=c++11}} | {{dcl rev begin | num=1 | since=c++11}} | ||
{{dcl | 1= | {{dcl | 1= | ||
− | template< class | + | template< class T > |
− | bool atomic_is_lock_free( const volatile | + | bool atomic_is_lock_free( const volatile std::atomic<T>* obj ); |
}} | }} | ||
{{dcl | 1= | {{dcl | 1= | ||
− | template< class | + | template< class T > |
− | bool atomic_is_lock_free( const | + | bool atomic_is_lock_free( const std::atomic<T>* obj ); |
}} | }} | ||
{{dcl rev end}} | {{dcl rev end}} | ||
Line 60: | Line 60: | ||
{{dsc tfun | cpp/memory/shared_ptr/atomic | title=std::atomic_is_lock_free{{dsc small|(std::shared_ptr)}} | specializes atomic operations for {{lc|std::shared_ptr}} }} | {{dsc tfun | cpp/memory/shared_ptr/atomic | title=std::atomic_is_lock_free{{dsc small|(std::shared_ptr)}} | specializes atomic operations for {{lc|std::shared_ptr}} }} | ||
{{dsc inc | cpp/atomic/dsc atomic_flag}} | {{dsc inc | cpp/atomic/dsc atomic_flag}} | ||
+ | {{dsc see c | c/atomic/atomic_is_lock_free}} | ||
+ | {{dsc see c | c/atomic/ATOMIC_LOCK_FREE_consts | ATOMIC_*_LOCK_FREE}} | ||
{{dsc end}} | {{dsc end}} | ||
Revision as of 06:10, 31 January 2015
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 */ |
(2) | (since C++11) |
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.- 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.
Contents |
Parameters
obj | - | pointer to the atomic object to examine |
Return value
true if *obj is a lock-free atomic, false otherwise.
Exceptions
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.
Example
This section is incomplete Reason: no example |
See also
checks if the atomic object is lock-free (public member function of std::atomic<T> )
| |
specializes atomic operations for std::shared_ptr (function template) | |
(C++11) |
the lock-free boolean atomic type (class) |
C documentation for atomic_is_lock_free
| |
C documentation for ATOMIC_*_LOCK_FREE
|