|
EnTT 4.0.0
|
Cooperative scheduler for processes. More...
#include <scheduler.hpp>
Public Types | |
| using | type = base_type |
| Process type. | |
| using | allocator_type = Allocator |
| Allocator type. | |
| using | size_type = stl::size_t |
| Unsigned integer type. | |
| using | delta_type = Delta |
| Unsigned integer type. | |
Public Member Functions | |
| basic_scheduler () | |
| Default constructor. | |
| basic_scheduler (const allocator_type &allocator) | |
| Constructs a scheduler with a given allocator. | |
| basic_scheduler (const basic_scheduler &)=delete | |
| Default copy constructor, deleted on purpose. | |
| basic_scheduler (basic_scheduler &&other) noexcept | |
| Move constructor. | |
| basic_scheduler (basic_scheduler &&other, const allocator_type &allocator) | |
| Allocator-extended move constructor. | |
| ~basic_scheduler ()=default | |
| Default destructor. | |
| basic_scheduler & | operator= (const basic_scheduler &)=delete |
| Default copy assignment operator, deleted on purpose. | |
| basic_scheduler & | operator= (basic_scheduler &&other) noexcept |
| Move assignment operator. | |
| void | swap (basic_scheduler &other) noexcept |
| Exchanges the contents with those of a given scheduler. | |
| constexpr allocator_type | get_allocator () const noexcept |
| Returns the associated allocator. | |
| size_type | size () const noexcept |
| Number of processes currently scheduled. | |
| bool | empty () const noexcept |
| Returns true if at least a process is currently scheduled. | |
| void | clear () |
| Discards all scheduled processes. | |
| template<typename Type, typename... Args> | |
| type & | attach (Args &&...args) |
| Schedules a process for the next tick. | |
| template<typename Func> | |
| type & | attach (Func func) |
| Schedules a process for the next tick. | |
| void | update (const delta_type delta, void *data=nullptr) |
| Updates all scheduled processes. | |
| void | abort (const bool immediate=false) |
| Aborts all scheduled processes. | |
Cooperative scheduler for processes.
A cooperative scheduler runs processes and helps managing their life cycles.
Each process is invoked once per tick. If a process terminates, it's removed automatically from the scheduler and it's never invoked again.
A process can also have a child. In this case, the process is replaced with its child when it terminates if it returns with success. In case of errors, both the process and its child are discarded.
In order to invoke all scheduled processes, call the update member function passing it the elapsed time to forward to the tasks.
| Delta | Type to use to provide elapsed time. |
| Allocator | Type of allocator used to manage memory and elements. |
Definition at line 36 of file scheduler.hpp.
| using entt::basic_scheduler< Delta, Allocator >::allocator_type = Allocator |
Allocator type.
Definition at line 46 of file scheduler.hpp.
| using entt::basic_scheduler< Delta, Allocator >::delta_type = Delta |
Unsigned integer type.
Definition at line 50 of file scheduler.hpp.
| using entt::basic_scheduler< Delta, Allocator >::size_type = stl::size_t |
Unsigned integer type.
Definition at line 48 of file scheduler.hpp.
| using entt::basic_scheduler< Delta, Allocator >::type = base_type |
Process type.
Definition at line 44 of file scheduler.hpp.
|
inline |
Default constructor.
Definition at line 53 of file scheduler.hpp.
|
inlineexplicit |
Constructs a scheduler with a given allocator.
| allocator | The allocator to use. |
Definition at line 60 of file scheduler.hpp.
|
inlinenoexcept |
Move constructor.
| other | The instance to move from. |
Definition at line 70 of file scheduler.hpp.
|
inline |
Allocator-extended move constructor.
| other | The instance to move from. |
| allocator | The allocator to use. |
Definition at line 78 of file scheduler.hpp.
|
inline |
Aborts all scheduled processes.
Unless an immediate operation is requested, the abort is scheduled for the next tick. Processes won't be executed anymore in any case.
Once a process is fully aborted and thus finished, it's discarded along with its child, if any.
| immediate | Requests an immediate operation. |
Definition at line 211 of file scheduler.hpp.
|
inline |
Schedules a process for the next tick.
| Type | Type of process to create. |
| Args | Types of arguments to use to initialize the process. |
| args | Parameters to use to initialize the process. |
Definition at line 154 of file scheduler.hpp.
|
inline |
Schedules a process for the next tick.
| Func | Type of process to create. |
| func | Either a lambda or a functor to use as a process. |
Definition at line 166 of file scheduler.hpp.
|
inline |
Discards all scheduled processes.
Processes aren't aborted. They are discarded along with their children and never executed again.
Definition at line 142 of file scheduler.hpp.
|
inlinenodiscardnoexcept |
Returns true if at least a process is currently scheduled.
Definition at line 132 of file scheduler.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns the associated allocator.
Definition at line 116 of file scheduler.hpp.
|
inlinenoexcept |
Move assignment operator.
| other | The instance to move from. |
Definition at line 97 of file scheduler.hpp.
|
delete |
Default copy assignment operator, deleted on purpose.
|
inlinenodiscardnoexcept |
Number of processes currently scheduled.
Definition at line 124 of file scheduler.hpp.
|
inlinenoexcept |
Exchanges the contents with those of a given scheduler.
| other | Scheduler to exchange the content with. |
Definition at line 107 of file scheduler.hpp.
|
inline |
Updates all scheduled processes.
All scheduled processes are executed in no specific order.
If a process terminates with success, it's replaced with its child, if any. Otherwise, if a process terminates with an error, it's removed along with its child.
| delta | Elapsed time. |
| data | Optional data. |
Definition at line 183 of file scheduler.hpp.