![]() |
TrinityCore
|
#include <TaskScheduler.h>
Classes | |
| struct | Compare |
| Container which provides Task order, insert and reschedule operations. More... | |
| class | Task |
| 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 |
| template<typename P > | |
| TaskScheduler & | SetValidator (P &&predicate) |
| Sets a validator which is asked if tasks are allowed to be executed. More... | |
| TaskScheduler & | ClearValidator () |
| Clears the validator which is asked if tasks are allowed to be executed. More... | |
| TaskScheduler & | Update (success_t const &callback=EmptyCallback) |
| TaskScheduler & | Update (size_t const milliseconds, success_t const &callback=EmptyCallback) |
| template<class _Rep , class _Period > | |
| TaskScheduler & | Update (std::chrono::duration< _Rep, _Period > const &difftime, success_t const &callback=EmptyCallback) |
| TaskScheduler & | Async (std::function< void()> const &callable) |
| template<class _Rep , class _Period > | |
| TaskScheduler & | Schedule (std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task) |
| template<class _Rep , class _Period > | |
| TaskScheduler & | Schedule (std::chrono::duration< _Rep, _Period > const &time, group_t const group, task_handler_t const &task) |
| template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight > | |
| TaskScheduler & | Schedule (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max, task_handler_t const &task) |
| template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight > | |
| TaskScheduler & | Schedule (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max, group_t const group, task_handler_t const &task) |
| TaskScheduler & | CancelAll () |
| TaskScheduler & | CancelGroup (group_t const group) |
| TaskScheduler & | CancelGroupsOf (std::vector< group_t > const &groups) |
| template<class _Rep , class _Period > | |
| TaskScheduler & | DelayAll (std::chrono::duration< _Rep, _Period > const &duration) |
| Delays all tasks with the given duration. More... | |
| template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight > | |
| TaskScheduler & | DelayAll (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max) |
| Delays all tasks with a random duration between min and max. More... | |
| template<class _Rep , class _Period > | |
| TaskScheduler & | DelayGroup (group_t const group, std::chrono::duration< _Rep, _Period > const &duration) |
| Delays all tasks of a group with the given duration. More... | |
| template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight > | |
| TaskScheduler & | DelayGroup (group_t const group, std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max) |
| Delays all tasks of a group with a random duration between min and max. More... | |
| template<class _Rep , class _Period > | |
| TaskScheduler & | RescheduleAll (std::chrono::duration< _Rep, _Period > const &duration) |
| Reschedule all tasks with a given duration. More... | |
| template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight > | |
| TaskScheduler & | RescheduleAll (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max) |
| Reschedule all tasks with a random duration between min and max. More... | |
| template<class _Rep , class _Period > | |
| TaskScheduler & | RescheduleGroup (group_t const group, std::chrono::duration< _Rep, _Period > const &duration) |
| Reschedule all tasks of a group with the given duration. More... | |
| template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight > | |
| TaskScheduler & | RescheduleGroup (group_t const group, std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max) |
| Reschedule all tasks of a group with a random duration between min and max. More... | |
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 std::function< void(TaskContext)> | task_handler_t |
| typedef std::function< bool()> | predicate_t |
| typedef std::function< void()> | success_t |
| typedef std::shared_ptr< Task > | TaskContainer |
| typedef std::queue < std::function< void()> > | AsyncHolder |
Private Member Functions | |
| TaskScheduler & | InsertTask (TaskContainer task) |
| Insert a new task to the enqueued tasks. More... | |
| template<class _Rep , class _Period > | |
| TaskScheduler & | ScheduleAt (timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task) |
| template<class _Rep , class _Period > | |
| TaskScheduler & | ScheduleAt (timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, group_t const group, task_handler_t const &task) |
| void | Dispatch (success_t const &callback) |
| Dispatch remaining tasks. More... | |
Static Private Member Functions | |
| static bool | EmptyValidator () |
| static void | EmptyCallback () |
| template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight > | |
| static std::chrono::milliseconds | RandomDurationBetween (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max) |
Private Attributes | |
| std::shared_ptr< TaskScheduler > | self_reference |
| Contains a self reference to track if this object was deleted or not. More... | |
| timepoint_t | _now |
| The current time point (now) More... | |
| TaskQueue | _task_holder |
| The Task Queue which contains all task objects. More... | |
| AsyncHolder | _asyncHolder |
| 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:
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
|
inline |
|
delete |
|
delete |
| TaskScheduler & TaskScheduler::Async | ( | std::function< void()> const & | callable | ) |
Schedule an callable function that is executed at the next update tick. Its safe to modify the TaskScheduler from within the callable.
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
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::CancelGroup | ( | group_t const | group | ) |
Cancel all tasks of a single group. Never call this from within a task context! Use TaskContext::CancelGroup instead!
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::CancelGroupsOf | ( | std::vector< group_t > const & | groups | ) |
Cancels all groups in the given std::vector. Hint: Use std::initializer_list for this: "{1, 2, 3, 4}"
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::ClearValidator | ( | ) |
Clears the validator which is asked if tasks are allowed to be executed.
Here is the call graph for this function:
|
inline |
Delays all tasks with the given duration.
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.
|
inline |
Delays all tasks of a group with the given duration.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Delays all tasks of a group with a random duration between min and max.
Dispatch remaining tasks.
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.
Here is the call graph for this function:
Here is the caller graph for this function:
|
delete |
|
delete |
|
inlinestaticprivate |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Reschedule all tasks with a given duration.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Reschedule all tasks with a random duration between min and max.
|
inline |
Reschedule all tasks of a group with the given duration.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Reschedule all tasks of a group with a random duration between min and max.
|
inline |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!
Here is the caller graph for this function:
|
inline |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!
|
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!
|
inline |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!
|
inlineprivate |
Here is the caller graph for this function:
|
inlineprivate |
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::schedule instead!
|
inline |
Sets a validator which is asked if tasks are allowed to be executed.
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::Update | ( | success_t const & | callback = EmptyCallback | ) |
Update the scheduler to the current time. Calls the optional callback on successfully finish.
Here is the call graph for this function:
Here is the caller graph for this function:| TaskScheduler & TaskScheduler::Update | ( | size_t const | milliseconds, |
| success_t const & | callback = EmptyCallback |
||
| ) |
Update the scheduler with a difftime in ms. Calls the optional callback on successfully finish.
Here is the call graph for this function:
|
inline |
Update the scheduler with a difftime. Calls the optional callback on successfully finish.
|
friend |
|
private |
Contains all asynchronous tasks which will be invoked at the next update tick.
|
private |
The current time point (now)
|
private |
|
private |
Contains a self reference to track if this object was deleted or not.
1.8.8