![]() |
TrinityCore
|
#include <TaskScheduler.h>
Classes | |
| struct | Compare |
| Container which provides Task order, insert and reschedule operations. More... | |
| class | Task |
| class | TaskHandler |
| class | TaskQueue |
Public Member Functions | |
| TaskScheduler () | |
| template<typename P > | |
| TaskScheduler (P &&predicate) | |
| TaskScheduler (TaskScheduler const &)=delete | |
| TaskScheduler (TaskScheduler &&)=delete | |
| TaskScheduler & | operator= (TaskScheduler const &)=delete |
| TaskScheduler & | operator= (TaskScheduler &&)=delete |
| ~TaskScheduler () | |
| template<typename P > | |
| TaskScheduler & | SetValidator (P &&predicate) |
| Sets a validator which is asked if tasks are allowed to be executed. | |
| TaskScheduler & | ClearValidator () |
| Clears the validator which is asked if tasks are allowed to be executed. | |
| TaskScheduler & | Update () |
| Update the scheduler to the current time. | |
| TaskScheduler & | Update (success_t callback) |
| TaskScheduler & | Update (size_t milliseconds) |
| Update the scheduler with a difftime in ms. | |
| TaskScheduler & | Update (size_t milliseconds, success_t callback) |
| TaskScheduler & | Update (duration_t difftime) |
| Update the scheduler with a difftime. | |
| TaskScheduler & | Update (duration_t difftime, success_t callback) |
| TaskScheduler & | Async (std::function< void()> callable) |
| TaskScheduler & | Schedule (duration_t time, task_handler_t task) |
| TaskScheduler & | Schedule (duration_t time, group_t group, task_handler_t task) |
| TaskScheduler & | Schedule (std::chrono::milliseconds min, std::chrono::milliseconds max, task_handler_t task) |
| TaskScheduler & | Schedule (std::chrono::milliseconds min, std::chrono::milliseconds max, group_t group, task_handler_t task) |
| TaskScheduler & | CancelAll () |
| TaskScheduler & | CancelGroup (group_t group) |
| TaskScheduler & | CancelGroupsOf (std::span< group_t > groups) |
| TaskScheduler & | DelayAll (duration_t duration) |
| Delays all tasks with the given duration. | |
| TaskScheduler & | DelayAll (std::chrono::milliseconds min, std::chrono::milliseconds max) |
| Delays all tasks with a random duration between min and max. | |
| TaskScheduler & | DelayGroup (group_t group, duration_t duration) |
| Delays all tasks of a group with the given duration. | |
| TaskScheduler & | DelayGroup (group_t group, std::chrono::milliseconds min, std::chrono::milliseconds max) |
| Delays all tasks of a group with a random duration between min and max. | |
| TaskScheduler & | RescheduleAll (duration_t duration) |
| Reschedule all tasks with a given duration. | |
| TaskScheduler & | RescheduleAll (std::chrono::milliseconds min, std::chrono::milliseconds max) |
| Reschedule all tasks with a random duration between min and max. | |
| TaskScheduler & | RescheduleGroup (group_t group, duration_t duration) |
| Reschedule all tasks of a group with the given duration. | |
| TaskScheduler & | RescheduleGroup (group_t group, std::chrono::milliseconds min, std::chrono::milliseconds max) |
| Reschedule all tasks of a group with a random duration between min and max. | |
Static Public Attributes | |
| static success_t const | EmptySuccessCallback |
Private Types | |
| typedef std::chrono::steady_clock | clock_t |
| typedef clock_t::time_point | timepoint_t |
| typedef clock_t::duration | duration_t |
| typedef uint32 | group_t |
| typedef uint32 | repeated_t |
| typedef TaskHandler | task_handler_t |
| typedef std::function< bool()> | predicate_t |
| typedef std::function< void()> | success_t |
| typedef std::shared_ptr< Task > | TaskContainer |
Private Member Functions | |
| TaskScheduler & | InsertTask (TaskContainer &&task) |
| Insert a new task to the enqueued tasks. | |
| TaskScheduler & | InsertTask (TaskQueue::Container::node_type &&node) |
| Insert a new task to the enqueued tasks. | |
| TaskScheduler & | ScheduleAt (timepoint_t end, duration_t time, task_handler_t task) |
| TaskScheduler & | ScheduleAt (timepoint_t end, duration_t time, group_t group, task_handler_t task) |
| void | Dispatch (success_t const &callback) |
| Dispatch remaining tasks. | |
Static Private Member Functions | |
| static bool | EmptyValidator () |
Private Attributes | |
| std::shared_ptr< TaskScheduler > | self_reference |
| Contains a self reference to track if this object was deleted or not. | |
| timepoint_t | _now |
| The current time point (now) | |
| TaskQueue | _task_holder |
| The Task Queue which contains all task objects. | |
| predicate_t | _predicate |
Friends | |
| class | TaskContext |
The TaskScheduler class provides the ability to schedule std::function's in the near future. Use TaskScheduler::Update to update the scheduler. Popular methods are:
Definition at line 48 of file TaskScheduler.h.
|
private |
Definition at line 55 of file TaskScheduler.h.
|
private |
Definition at line 57 of file TaskScheduler.h.
|
private |
Definition at line 60 of file TaskScheduler.h.
|
private |
Definition at line 66 of file TaskScheduler.h.
|
private |
Definition at line 62 of file TaskScheduler.h.
|
private |
Definition at line 68 of file TaskScheduler.h.
|
private |
Definition at line 64 of file TaskScheduler.h.
|
private |
Definition at line 155 of file TaskScheduler.h.
|
private |
Definition at line 56 of file TaskScheduler.h.
| TaskScheduler::TaskScheduler | ( | ) |
Definition at line 23 of file TaskScheduler.cpp.
|
inlineexplicit |
Definition at line 215 of file TaskScheduler.h.
|
delete |
|
delete |
|
default |
| TaskScheduler & TaskScheduler::Async | ( | std::function< void()> | callable | ) |
Schedule an callable function that is executed at the next update tick. Its safe to modify the TaskScheduler from within the callable.
Definition at line 80 of file TaskScheduler.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::CancelAll | ( | ) |
Cancels all tasks. Never call this from within a task context! Use TaskContext::CancelAll instead!
Clear the task holder
Definition at line 86 of file TaskScheduler.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::CancelGroup | ( | group_t | group | ) |
Cancel all tasks of a single group. Never call this from within a task context! Use TaskContext::CancelGroup instead!
Definition at line 93 of file TaskScheduler.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::CancelGroupsOf | ( | std::span< group_t > | groups | ) |
Cancels all groups in the given std::span. Hint: Use std::initializer_list for this: "{1, 2, 3, 4}"
Definition at line 102 of file TaskScheduler.cpp.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::ClearValidator | ( | ) |
Clears the validator which is asked if tasks are allowed to be executed.
Definition at line 32 of file TaskScheduler.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::DelayAll | ( | duration_t | duration | ) |
Delays all tasks with the given duration.
Definition at line 111 of file TaskScheduler.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Delays all tasks with a random duration between min and max.
Definition at line 312 of file TaskScheduler.h.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::DelayGroup | ( | group_t | group, |
| duration_t | duration | ||
| ) |
Delays all tasks of a group with the given duration.
Definition at line 121 of file TaskScheduler.cpp.
Here is the call graph for this function:
|
inline |
Delays all tasks of a group with a random duration between min and max.
Definition at line 322 of file TaskScheduler.h.
Here is the call graph for this function:
|
private |
Dispatch remaining tasks.
Definition at line 186 of file TaskScheduler.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestaticprivate |
|
private |
Insert a new task to the enqueued tasks.
Definition at line 163 of file TaskScheduler.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Insert a new task to the enqueued tasks.
Definition at line 169 of file TaskScheduler.cpp.
Here is the call graph for this function:
|
delete |
|
delete |
| TaskScheduler & TaskScheduler::RescheduleAll | ( | duration_t | duration | ) |
Reschedule all tasks with a given duration.
Definition at line 136 of file TaskScheduler.cpp.
Here is the call graph for this function:
|
inline |
Reschedule all tasks with a random duration between min and max.
Definition at line 333 of file TaskScheduler.h.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::RescheduleGroup | ( | group_t | group, |
| duration_t | duration | ||
| ) |
Reschedule all tasks of a group with the given duration.
Definition at line 147 of file TaskScheduler.cpp.
Here is the call graph for this function:
|
inline |
Reschedule all tasks of a group with a random duration between min and max.
Definition at line 342 of file TaskScheduler.h.
Here is the call graph for this function:
|
inline |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!
Definition at line 273 of file TaskScheduler.h.
|
inline |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!
Definition at line 265 of file TaskScheduler.h.
|
inline |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!
Definition at line 289 of file TaskScheduler.h.
Here is the call graph for this function:
|
inline |
Schedule an event with a randomized rate between min and max rate. Never call this from within a task context! Use TaskContext::Schedule instead!
Definition at line 281 of file TaskScheduler.h.
Here is the call graph for this function:
|
private |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::schedule instead!
Definition at line 180 of file TaskScheduler.cpp.
Here is the call graph for this function:
|
private |
|
inline |
Sets a validator which is asked if tasks are allowed to be executed.
Definition at line 227 of file TaskScheduler.h.
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::Update | ( | ) |
Update the scheduler to the current time.
Definition at line 38 of file TaskScheduler.cpp.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::Update | ( | duration_t | difftime | ) |
Update the scheduler with a difftime.
Definition at line 66 of file TaskScheduler.cpp.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::Update | ( | duration_t | difftime, |
| success_t | callback | ||
| ) |
Update the scheduler with a difftime. Calls the optional callback on successfully finish.
Definition at line 73 of file TaskScheduler.cpp.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::Update | ( | size_t | milliseconds | ) |
Update the scheduler with a difftime in ms.
Definition at line 52 of file TaskScheduler.cpp.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::Update | ( | size_t | milliseconds, |
| success_t | callback | ||
| ) |
Update the scheduler with a difftime in ms. Calls the optional callback on successfully finish.
Definition at line 59 of file TaskScheduler.cpp.
Here is the call graph for this function:| TaskScheduler & TaskScheduler::Update | ( | success_t | callback | ) |
Update the scheduler to the current time. Calls the optional callback on successfully finish.
Definition at line 45 of file TaskScheduler.cpp.
Here is the call graph for this function:
|
friend |
Definition at line 50 of file TaskScheduler.h.
|
private |
The current time point (now)
Definition at line 199 of file TaskScheduler.h.
|
private |
Definition at line 204 of file TaskScheduler.h.
|
private |
The Task Queue which contains all task objects.
Definition at line 202 of file TaskScheduler.h.
|
static |
Definition at line 236 of file TaskScheduler.h.
|
private |
Contains a self reference to track if this object was deleted or not.
Definition at line 196 of file TaskScheduler.h.