|
swift
|
Lock-free wrapper for synchronizing multi-threaded access to an object. More...
#include <lockfree.h>
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. | |
| 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. | |
| 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 147 of file lockfree.h.
|
inline |
Construct by copying from a T.
Definition at line 154 of file lockfree.h.
|
inlinenoexcept |
Construct by moving from a T.
Definition at line 157 of file lockfree.h.
|
inline |
Return an object which can read the current value.
Definition at line 173 of file lockfree.h.
|
inline |
Pass the current value to the functor inspector, and return whatever inspector returns.
Definition at line 185 of file lockfree.h.
|
inline |
Return an object which can write a new value, as long as there are no other writes.
Definition at line 180 of file lockfree.h.
|
inline |
Pass a modifiable reference to the functor mutator. Unsafe if there are multiple writers.
Definition at line 192 of file lockfree.h.