|
callonce
1.0.0
Header-only memoized call-once wrapper for any C++ callable
|
Execution policy with no synchronisation overhead. The CTAD default. More...
#include <memoized_invoke.hh>
Public Member Functions | |
| bool | try_enter () |
| Attempt to move from the not-started/running state into running. More... | |
| void | mark_done () noexcept |
| Transition to the done state. Called after a successful invocation. More... | |
| void | mark_free () noexcept |
| Transition back to not-started. Called on reset and on exception rollback. More... | |
| bool | is_done () const noexcept |
| void | wait () const noexcept |
| No-op: a single-threaded caller is never actually blocked. More... | |
Private Attributes | |
| detail::execution_state | state_ { detail::execution_state::not_started } |
Execution policy with no synchronisation overhead. The CTAD default.
single_threaded implements the ExecutionPolicy interface expected by memoized_invoke using a plain, non-atomic state variable. Every operation is a single unsynchronised load or store, so there is no cost beyond that of a bare enum.
|
inline |
Attempt to move from the not-started/running state into running.
false once the state is done (nothing left to do); true otherwise, after setting the state to running. References fedem::utility::detail::done, fedem::utility::detail::running, and state_.
|
inlinenoexcept |
Transition to the done state. Called after a successful invocation.
References fedem::utility::detail::done, and state_.
|
inlinenoexcept |
Transition back to not-started. Called on reset and on exception rollback.
References fedem::utility::detail::not_started, and state_.
|
inlinenoexcept |
true if the callable has run to completion and the value is cached. References fedem::utility::detail::done, and state_.
|
inlinenoexcept |
No-op: a single-threaded caller is never actually blocked.
|
private |
Referenced by is_done(), mark_done(), mark_free(), and try_enter().