Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <atom.hpp>
Classes | |
struct | get_gc_atom_impl |
struct | get_refcount_atom_impl |
Public Types | |
using | box_type = box< T, MemoryPolicy > |
using | value_type = T |
using | memory_policy = MemoryPolicy |
Public Member Functions | |
atom (const atom &)=delete | |
atom (atom &&)=delete | |
void | operator= (const atom &)=delete |
void | operator= (atom &&)=delete |
atom (box_type v={}) | |
atom & | operator= (box_type b) |
operator box_type () const | |
operator value_type () const | |
box_type | load () const |
void | store (box_type b) |
box_type | exchange (box_type b) |
template<typename Fn > | |
box_type | update (Fn &&fn) |
Private Types | |
using | impl_t = typename std::conditional_t< std::is_same< typename MemoryPolicy::refcount, no_refcount_policy >::value, get_gc_atom_impl, get_refcount_atom_impl >::template apply< T, MemoryPolicy >::type |
Private Attributes | |
impl_t | impl_ |
Detailed Description
template<typename T, typename MemoryPolicy = default_memory_policy>
class immer::atom< T, MemoryPolicy >
Stores for boxed values of type T
in a thread-safe manner.
- See also
- box
.. warning:: If memory policy used includes thread unsafe reference counting, no no thread safety is assumed, and the atom becomes thread unsafe too!
.. note:: box<T>
provides a value based box of type T
, this is, we can think about it as a value-based version of std::shared_ptr
. In a similar fashion, atom<T>
is in spirit the value-based equivalent of C++20 std::atomic_shared_ptr
. However, the API does not follow std::atomic
interface closely, since it attempts to be a higher level construction, most similar to Clojure's (atom)
. It is remarkable in particular that, since box<T>
underlying object is immutable, using atom<T>
is fully thread-safe in ways that std::atmic_shared_ptr
is not. This is so because dereferencing the underlying pointer in a std::atomic_share_ptr
may require further synchronization, in particular when invoking non-const methods.
Member Typedef Documentation
◆ box_type
using immer::atom< T, MemoryPolicy >::box_type = box<T, MemoryPolicy> |
◆ impl_t
|
private |
◆ memory_policy
using immer::atom< T, MemoryPolicy >::memory_policy = MemoryPolicy |
◆ value_type
using immer::atom< T, MemoryPolicy >::value_type = T |
Constructor & Destructor Documentation
◆ atom() [1/3]
|
delete |
◆ atom() [2/3]
|
delete |
◆ atom() [3/3]
|
inline |
Member Function Documentation
◆ exchange()
|
inline |
Stores a new value and returns the old value, in a thread-safe manner.
Definition at line 209 of file atom.hpp.
References immer::atom< T, MemoryPolicy >::impl_.
◆ load()
|
inline |
Reads the currently stored value in a thread-safe manner.
Definition at line 197 of file atom.hpp.
References immer::atom< T, MemoryPolicy >::impl_.
◆ operator box_type()
|
inline |
Reads the currently stored value in a thread-safe manner.
Definition at line 185 of file atom.hpp.
References immer::atom< T, MemoryPolicy >::impl_.
◆ operator value_type()
|
inline |
Reads the currently stored value in a thread-safe manner.
Definition at line 191 of file atom.hpp.
References immer::atom< T, MemoryPolicy >::impl_.
◆ operator=() [1/3]
|
delete |
◆ operator=() [2/3]
|
delete |
◆ operator=() [3/3]
|
inline |
Sets a new value in the atom.
Definition at line 176 of file atom.hpp.
References immer::atom< T, MemoryPolicy >::impl_.
◆ store()
|
inline |
Stores a new value in a thread-safe manner.
Definition at line 203 of file atom.hpp.
References immer::atom< T, MemoryPolicy >::impl_.
◆ update()
|
inline |
Stores the result of applying fn
to the current value atomically and returns the new resulting value.
.. warning:: fn
must be a pure function and have no side effects! The function might be evaluated multiple times when multiple threads content to update the value.
Definition at line 225 of file atom.hpp.
References immer::atom< T, MemoryPolicy >::impl_.
Member Data Documentation
◆ impl_
|
private |
Definition at line 256 of file atom.hpp.
Referenced by immer::atom< T, MemoryPolicy >::exchange(), immer::atom< T, MemoryPolicy >::load(), immer::atom< T, MemoryPolicy >::operator box_type(), immer::atom< T, MemoryPolicy >::operator value_type(), immer::atom< T, MemoryPolicy >::operator=(), immer::atom< T, MemoryPolicy >::store(), and immer::atom< T, MemoryPolicy >::update().
The documentation for this class was generated from the following file:
- src/immer/atom.hpp