EnTT 3.14.0
|
Adaptor for lambdas and functors to turn them into processes. More...
#include <process.hpp>
Public Member Functions | |
template<typename... Args> | |
process_adaptor (Args &&...args) | |
Constructs a process adaptor from a lambda or a functor. | |
void | update (const Delta delta, void *data) |
Updates a process and its internal state if required. | |
Public Member Functions inherited from entt::process< process_adaptor< Func, Delta >, Delta > | |
constexpr | process ()=default |
Default constructor. | |
process (const process &)=default | |
Default copy constructor. | |
process (process &&) noexcept=default | |
Default move constructor. | |
process & | operator= (const process &)=default |
Default copy assignment operator. | |
process & | operator= (process &&) noexcept=default |
Default move assignment operator. | |
virtual | ~process () |
Default destructor. | |
void | abort (const bool immediate=false) |
Aborts a process if it's still alive. | |
bool | alive () const noexcept |
Returns true if a process is either running or paused. | |
bool | finished () const noexcept |
Returns true if a process is already terminated. | |
bool | paused () const noexcept |
Returns true if a process is currently paused. | |
bool | rejected () const noexcept |
Returns true if a process terminated with errors. | |
void | tick (const Delta delta, void *data=nullptr) |
Updates a process and its internal state if required. | |
Additional Inherited Members | |
Public Types inherited from entt::process< process_adaptor< Func, Delta >, Delta > | |
using | delta_type |
Type used to provide elapsed time. | |
Protected Member Functions inherited from entt::process< process_adaptor< Func, Delta >, Delta > | |
void | succeed () noexcept |
Terminates a process with success if it's still alive. | |
void | fail () noexcept |
Terminates a process with errors if it's still alive. | |
void | pause () noexcept |
Stops a process if it's in a running state. | |
void | unpause () noexcept |
Restarts a process if it's paused. | |
Adaptor for lambdas and functors to turn them into processes.
Lambdas and functors can't be used directly with a scheduler for they are not properly defined processes with managed life cycles.
This class helps in filling the gap and turning lambdas and functors into full featured processes usable by a scheduler.
The signature of the function call operator should be equivalent to the following:
Where:
delta
is the elapsed time.data
is an opaque pointer to user data if any, nullptr
otherwise.succeed
is a function to call when a process terminates with success.fail
is a function to call when a process terminates with errors.The signature of the function call operator of both succeed
and fail
is equivalent to the following:
Usually users shouldn't worry about creating adaptors. A scheduler will create them internally each and avery time a lambda or a functor is used as a process.
Func | Actual type of process. |
Delta | Type to use to provide elapsed time. |
Definition at line 328 of file process.hpp.
|
inline |
Constructs a process adaptor from a lambda or a functor.
Args | Types of arguments to use to initialize the actual process. |
args | Parameters to use to initialize the actual process. |
Definition at line 335 of file process.hpp.
Updates a process and its internal state if required.
delta | Elapsed time. |
data | Optional data. |
Definition at line 343 of file process.hpp.