Executes the supplied code block a single time. More...
#include <SingleTimeExecutor.hpp>
Public Member Functions | |
SingleTimeExecutor (std::function< void()> code_) | |
Create a single time executor with a code block. More... | |
SingleTimeExecutor (std::function< void()> code_, std::function< void()> destructorCode_) | |
Create a single time executor with a code block and a destructor code block. More... | |
~SingleTimeExecutor () | |
Destroy the single time executor. More... | |
std::mutex & | getMutex () |
Get the internal mutex in order to synchronise on external code. More... | |
bool | hasExecuted () const |
Returns true if the code has been executed. More... | |
void | operator() () |
Execute the code a single time. More... | |
Executes the supplied code block a single time.
Optionally register a code block to run in the destructor, only if the execution has happened.
|
inlineexplicit |
Create a single time executor with a code block.
|
inline |
Create a single time executor with a code block and a destructor code block.
The executor will execute the first supplied code block a single time and will execute the second supplied code block if the first had already been executed at the time of destruction.
|
inline |
Destroy the single time executor.
|
inline |
Get the internal mutex in order to synchronise on external code.
Use with care.
|
inline |
Returns true if the code has been executed.
If the operator () is being concurrently run in other threads whilst this method is called, this method will not necessarily reflect any objective reality to whether the code has been run at the time of the call. This method should thus only be used when there is no possibility of the operator () being run in other threads, otherwise it will return a meaningless result.
|
inline |
Execute the code a single time.