|
dispenso 1.6.0
A library for task parallelism
|
#include <once_function.h>
Public Member Functions | |
| OnceFunction () | |
| template<typename F > | |
| OnceFunction (F &&f) | |
| OnceFunction (const OnceFunction &other)=delete | |
| OnceFunction (OnceFunction &&other) noexcept | |
| void | cleanupNotRun () |
A class fullfilling the void() signature, and operator() must be called exactly once for valid OnceFunctions. This class can be much more efficient than std::function for type erasing functors without too much state (currently 56 bytes inline buffer).
Definition at line 54 of file once_function.h.
|
inline |
Construct a OnceFunction with invalid state.
Definition at line 59 of file once_function.h.
|
inline |
Construct a OnceFunction with a valid functor.
| f | A functor with signature void(). Ideally this should be a concrete functor (e.g. from lambda), though it will work with e.g. std::function. The downside in the latter case is extra overhead for double type erasure. |
Definition at line 75 of file once_function.h.
|
inlinenoexcept |
Move constructor. Copies the full 64-byte object (one cache line).
Definition at line 83 of file once_function.h.
|
inline |
Destroy the type-erased functor and release its resources without invoking it. Use this when a OnceFunction will not be called but its resources must still be freed. Like operator(), this must be called at most once, and the OnceFunction must not be used after.
Definition at line 110 of file once_function.h.