|
unilink
0.4.3
A simple C++ library for unified async communication
|
Thread-safe state management class. More...
#include <thread_safe_state.hpp>
Public Types | |
| using | State = StateType |
| using | StateCallback = std::function< void(const State &)> |
| using | StateCallbackHandle = size_t |
Public Member Functions | |
| ThreadSafeState (const State &initial_state=State{}) | |
| ThreadSafeState (const ThreadSafeState &)=delete | |
| ThreadSafeState & | operator= (const ThreadSafeState &)=delete |
| ThreadSafeState (ThreadSafeState &&)=delete | |
| ThreadSafeState & | operator= (ThreadSafeState &&)=delete |
| State | get_state () const |
| void | set_state (const State &new_state) |
| void | set_state (State &&new_state) |
| bool | compare_and_set (const State &expected, const State &desired) |
| State | exchange (const State &new_state) |
| StateCallbackHandle | add_state_change_callback (StateCallback callback) |
| void | remove_state_change_callback (StateCallbackHandle handle) |
| void | clear_state_change_callbacks () |
| void | wait_for_state (const State &expected_state, std::chrono::milliseconds timeout=std::chrono::milliseconds(1000)) |
| void | wait_for_state_change (std::chrono::milliseconds timeout=std::chrono::milliseconds(1000)) |
| bool | is_state (const State &expected_state) const |
| void | notify_state_change () |
Thread-safe state management class.
Provides thread-safe state management with read-write lock semantics. Multiple readers can access the state simultaneously, but only one writer can modify the state at a time.
Definition at line 41 of file thread_safe_state.hpp.
| using unilink::concurrency::ThreadSafeState< StateType >::State = StateType |
Definition at line 43 of file thread_safe_state.hpp.
| using unilink::concurrency::ThreadSafeState< StateType >::StateCallback = std::function<void(const State&)> |
Definition at line 44 of file thread_safe_state.hpp.
| using unilink::concurrency::ThreadSafeState< StateType >::StateCallbackHandle = size_t |
Definition at line 45 of file thread_safe_state.hpp.
|
explicit |
Definition at line 171 of file thread_safe_state.hpp.
|
delete |
|
delete |
| ThreadSafeState< StateType >::StateCallbackHandle unilink::concurrency::ThreadSafeState< StateType >::add_state_change_callback | ( | StateCallback | callback | ) |
Definition at line 230 of file thread_safe_state.hpp.
| void unilink::concurrency::ThreadSafeState< StateType >::clear_state_change_callbacks |
Definition at line 247 of file thread_safe_state.hpp.
| bool unilink::concurrency::ThreadSafeState< StateType >::compare_and_set | ( | const State & | expected, |
| const State & | desired | ||
| ) |
Definition at line 202 of file thread_safe_state.hpp.
| StateType unilink::concurrency::ThreadSafeState< StateType >::exchange | ( | const State & | new_state | ) |
Definition at line 216 of file thread_safe_state.hpp.
| StateType unilink::concurrency::ThreadSafeState< StateType >::get_state |
Definition at line 174 of file thread_safe_state.hpp.
| bool unilink::concurrency::ThreadSafeState< StateType >::is_state | ( | const State & | expected_state | ) | const |
Definition at line 266 of file thread_safe_state.hpp.
| void unilink::concurrency::ThreadSafeState< StateType >::notify_state_change |
Definition at line 272 of file thread_safe_state.hpp.
|
delete |
|
delete |
| void unilink::concurrency::ThreadSafeState< StateType >::remove_state_change_callback | ( | StateCallbackHandle | handle | ) |
Definition at line 239 of file thread_safe_state.hpp.
| void unilink::concurrency::ThreadSafeState< StateType >::set_state | ( | const State & | new_state | ) |
Definition at line 180 of file thread_safe_state.hpp.
| void unilink::concurrency::ThreadSafeState< StateType >::set_state | ( | State && | new_state | ) |
Definition at line 191 of file thread_safe_state.hpp.
| void unilink::concurrency::ThreadSafeState< StateType >::wait_for_state | ( | const State & | expected_state, |
| std::chrono::milliseconds | timeout = std::chrono::milliseconds(1000) |
||
| ) |
Definition at line 253 of file thread_safe_state.hpp.
| void unilink::concurrency::ThreadSafeState< StateType >::wait_for_state_change | ( | std::chrono::milliseconds | timeout = std::chrono::milliseconds(1000) | ) |
Definition at line 259 of file thread_safe_state.hpp.