unilink  0.4.3
A simple C++ library for unified async communication
unilink::concurrency::AtomicState< StateType > Class Template Reference

Thread-safe atomic state wrapper. More...

#include <thread_safe_state.hpp>

Public Types

using State = StateType
 

Public Member Functions

 AtomicState (const State &initial_state=State{})
 
State get () const noexcept
 
void set (const State &new_state) noexcept
 
void set (State &&new_state) noexcept
 
bool compare_and_set (const State &expected, const State &desired) noexcept
 
State exchange (const State &new_state) noexcept
 
bool is_state (const State &expected_state) const noexcept
 

Detailed Description

template<typename StateType>
class unilink::concurrency::AtomicState< StateType >

Thread-safe atomic state wrapper.

Lightweight wrapper for atomic state management when full thread-safe state management is not needed.

Definition at line 101 of file thread_safe_state.hpp.

Member Typedef Documentation

◆ State

template<typename StateType >
using unilink::concurrency::AtomicState< StateType >::State = StateType

Definition at line 103 of file thread_safe_state.hpp.

Constructor & Destructor Documentation

◆ AtomicState()

template<typename StateType >
unilink::concurrency::AtomicState< StateType >::AtomicState ( const State initial_state = State{})
explicit

Definition at line 290 of file thread_safe_state.hpp.

Member Function Documentation

◆ compare_and_set()

template<typename StateType >
bool unilink::concurrency::AtomicState< StateType >::compare_and_set ( const State expected,
const State desired 
)
noexcept

Definition at line 308 of file thread_safe_state.hpp.

◆ exchange()

template<typename StateType >
StateType unilink::concurrency::AtomicState< StateType >::exchange ( const State new_state)
noexcept

Definition at line 314 of file thread_safe_state.hpp.

◆ get()

template<typename StateType >
StateType unilink::concurrency::AtomicState< StateType >::get
noexcept

Definition at line 293 of file thread_safe_state.hpp.

◆ is_state()

template<typename StateType >
bool unilink::concurrency::AtomicState< StateType >::is_state ( const State expected_state) const
noexcept

Definition at line 319 of file thread_safe_state.hpp.

◆ set() [1/2]

template<typename StateType >
void unilink::concurrency::AtomicState< StateType >::set ( const State new_state)
noexcept

Definition at line 298 of file thread_safe_state.hpp.

◆ set() [2/2]

template<typename StateType >
void unilink::concurrency::AtomicState< StateType >::set ( State &&  new_state)
noexcept

Definition at line 303 of file thread_safe_state.hpp.


The documentation for this class was generated from the following file: