swift
|
Lock-free wrapper for synchronizing multi-threaded access to an object. More...
Public Member Functions | |
LockFree ()=default | |
Default constructor. Object will contain a default-constructed T. | |
LockFree (const T &other) | |
Construct by copying from a T. | |
LockFree (T &&other) noexcept(std::is_nothrow_move_assignable_v< T >) | |
Construct by moving from a T. | |
LockFreeReader< const T > | read () const |
Return an object which can read the current value. | |
LockFreeUniqueWriter< T > | uniqueWrite () |
Return an object which can write a new value, as long as there are no other writes. | |
LockFreeSharedWriter< T > | sharedWrite () |
Return an object which can write a new value, even if there are other writes. | |
template<typename F > | |
auto | read (F &&inspector) |
Pass the current value to the functor inspector, and return whatever inspector returns. | |
template<typename F > | |
void | uniqueWrite (F &&mutator) |
Pass a modifiable reference to the functor mutator. Unsafe if there are multiple writers. | |
template<typename F > | |
void | sharedWrite (F &&mutator) |
Pass a modifiable reference to the functor mutator. Safe if there are multiple writers. The mutator may be called multiple times. | |
LockFree (const LockFree &)=delete | |
LockFree cannot be copied or moved. | |
LockFree & | operator= (const LockFree &)=delete |
LockFree cannot be copied or moved. | |
LockFree (LockFree &&)=delete | |
LockFree cannot be copied or moved. | |
LockFree & | operator= (LockFree &&)=delete |
LockFree cannot be copied or moved. | |
Lock-free wrapper for synchronizing multi-threaded access to an object.
Implemented using atomic operations of std::shared_ptr.
Definition at line 218 of file lockfree.h.