AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
TaskScheduler Class Reference

#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
 
TaskScheduleroperator= (TaskScheduler const &)=delete
 
TaskScheduleroperator= (TaskScheduler &&)=delete
 
template<typename P >
TaskSchedulerSetValidator (P &&predicate)
 Sets a validator which is asked if tasks are allowed to be executed. More...
 
TaskSchedulerClearValidator ()
 Clears the validator which is asked if tasks are allowed to be executed. More...
 
TaskSchedulerUpdate (success_t const &callback=EmptyCallback)
 
TaskSchedulerUpdate (std::size_t const milliseconds, success_t const &callback=EmptyCallback)
 
template<class _Rep , class _Period >
TaskSchedulerUpdate (std::chrono::duration< _Rep, _Period > const &difftime, success_t const &callback=EmptyCallback)
 
TaskSchedulerAsync (std::function< void()> const &callable)
 
template<class _Rep , class _Period >
TaskSchedulerSchedule (std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
 
template<class _Rep , class _Period >
TaskSchedulerSchedule (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 >
TaskSchedulerSchedule (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 >
TaskSchedulerSchedule (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max, group_t const group, task_handler_t const &task)
 
TaskSchedulerCancelAll ()
 
TaskSchedulerCancelGroup (group_t const group)
 
TaskSchedulerCancelGroupsOf (std::vector< group_t > const &groups)
 
bool IsGroupScheduled (group_t const group)
 Check if the group exists and is currently scheduled. More...
 
template<class _Rep , class _Period >
TaskSchedulerDelayAll (std::chrono::duration< _Rep, _Period > const &duration)
 Delays all tasks with the given duration. More...
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskSchedulerDelayAll (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 >
TaskSchedulerDelayGroup (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 >
TaskSchedulerDelayGroup (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 >
TaskSchedulerRescheduleAll (std::chrono::duration< _Rep, _Period > const &duration)
 Reschedule all tasks with a given duration. More...
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskSchedulerRescheduleAll (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 >
TaskSchedulerRescheduleGroup (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 >
TaskSchedulerRescheduleGroup (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< TaskTaskContainer
 
typedef std::queue< std::function< void()> > AsyncHolder
 

Private Member Functions

TaskSchedulerInsertTask (TaskContainer task)
 Insert a new task to the enqueued tasks. More...
 
template<class _Rep , class _Period >
TaskSchedulerScheduleAt (timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
 
template<class _Rep , class _Period >
TaskSchedulerScheduleAt (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< TaskSchedulerself_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
 

Detailed Description

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:

  • Schedule (Schedules a std::function which will be executed in the near future).
  • Schedules an asynchronous function which will be executed at the next update tick.
  • Cancel, Delay & Reschedule (Methods to manipulate already scheduled tasks). Tasks are organized in groups (uint), multiple tasks can have the same group id, you can provide a group or not, but keep in mind that you can only manipulate specific tasks through its group id! Tasks callbacks use the function signature void(TaskContext) where TaskContext provides access to the function schedule plan which makes it possible to repeat the task with the same duration or a new one. It also provides access to the repeat counter which is useful for task that repeat itself often but behave different every time (spoken event dialogs for example).

Member Typedef Documentation

◆ AsyncHolder

typedef std::queue<std::function<void()> > TaskScheduler::AsyncHolder
private

◆ clock_t

typedef std::chrono::steady_clock TaskScheduler::clock_t
private

◆ duration_t

typedef clock_t::duration TaskScheduler::duration_t
private

◆ group_t

typedef uint32 TaskScheduler::group_t
private

◆ predicate_t

typedef std::function<bool()> TaskScheduler::predicate_t
private

◆ repeated_t

◆ success_t

typedef std::function<void()> TaskScheduler::success_t
private

◆ task_handler_t

typedef std::function<void(TaskContext)> TaskScheduler::task_handler_t
private

◆ TaskContainer

typedef std::shared_ptr<Task> TaskScheduler::TaskContainer
private

◆ timepoint_t

typedef clock_t::time_point TaskScheduler::timepoint_t
private

Constructor & Destructor Documentation

◆ TaskScheduler() [1/4]

TaskScheduler::TaskScheduler ( )
inline
182 : self_reference(this, [](TaskScheduler const*) { }), _now(clock_t::now()), _predicate(EmptyValidator) { }
Definition: TaskScheduler.h:45
std::shared_ptr< TaskScheduler > self_reference
Contains a self reference to track if this object was deleted or not.
Definition: TaskScheduler.h:155
predicate_t _predicate
Definition: TaskScheduler.h:169
timepoint_t _now
The current time point (now)
Definition: TaskScheduler.h:158
static bool EmptyValidator()
Definition: TaskScheduler.h:171

◆ TaskScheduler() [2/4]

template<typename P >
TaskScheduler::TaskScheduler ( P &&  predicate)
inline
185 : self_reference(this, [](TaskScheduler const*) { }), _now(clock_t::now()), _predicate(std::forward<P>(predicate)) { }

◆ TaskScheduler() [3/4]

TaskScheduler::TaskScheduler ( TaskScheduler const &  )
delete

◆ TaskScheduler() [4/4]

TaskScheduler::TaskScheduler ( TaskScheduler &&  )
delete

Member Function Documentation

◆ Async()

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.

40{
41 _asyncHolder.push(callable);
42 return *this;
43}
AsyncHolder _asyncHolder
Definition: TaskScheduler.h:167

References _asyncHolder.

Referenced by TaskContext::Async().

◆ CancelAll()

TaskScheduler & TaskScheduler::CancelAll ( )

Cancels all tasks. Never call this from within a task context! Use TaskContext::CancelAll instead!

Clear the task holder

46{
50 return *this;
51}
std::queue< std::function< void()> > AsyncHolder
Definition: TaskScheduler.h:163
TaskQueue _task_holder
The Task Queue which contains all task objects.
Definition: TaskScheduler.h:161
void Clear()
Definition: TaskScheduler.cpp:144

References _asyncHolder, _task_holder, and TaskScheduler::TaskQueue::Clear().

Referenced by BossAI::_JustDied(), BossAI::_Reset(), TaskContext::CancelAll(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::CleanupInstance(), npc_batrider::DamageTaken(), boss_essence_of_suffering::boss_essence_of_sufferingAI::DamageTaken(), boss_essence_of_desire::boss_essence_of_desireAI::DamageTaken(), boss_bug_trio::DamageTaken(), npc_drakonid_spawner::DoAction(), boss_illidan_stormrage::DoAction(), npc_maiev_illidan::DoAction(), npc_creature_generator_akama::DoAction(), boss_glob_of_viscidus::InitializeAI(), npc_inner_demon::IsSummonedBy(), npc_lord_sanguinar::JustDied(), npc_capernian::JustDied(), npc_telonicus::JustDied(), boss_thekal::JustEngagedWith(), npc_zealot_lorkhan::JustEngagedWith(), npc_zealot_zath::JustEngagedWith(), npc_anubisath_guardian::JustEngagedWith(), boss_nazan::JustEngagedWith(), boss_high_botanist_freywinn::JustEngagedWith(), boss_jindo::JustEngagedWith(), boss_grand_warlock_nethekurse::JustEngagedWith(), boss_illidan_stormrage::MovementInform(), boss_lady_vashj::MovementInform(), boss_shade_of_akama::MovementInform(), npc_shattered_hand_scout::MovementInform(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::OnUnitDeath(), boss_mor_grayhoof::Reset(), npc_corrupted_totem::Reset(), npc_lava_spawn::Reset(), boss_nightbane::Reset(), boss_servant_quarters::Reset(), boss_shade_of_aran::Reset(), npc_kilrek::Reset(), boss_vexallus::Reset(), boss_kormok::Reset(), npc_apothecary_baxter::Reset(), boss_baroness_anastari::boss_baroness_anastariAI::Reset(), boss_jarien::Reset(), boss_sothos::Reset(), boss_twilight_corrupter::Reset(), npc_halazzi_lynx::Reset(), boss_nalorakk::Reset(), npc_batrider::Reset(), npc_healing_ward::Reset(), npc_shade_of_jindo::Reset(), npc_ohgan::npc_ohganAI::Reset(), npc_vilebranch_speaker::Reset(), npc_spawn_of_marli::Reset(), boss_thekal::Reset(), npc_zealot_lorkhan::Reset(), npc_zealot_zath::Reset(), boss_azuregos::boss_azuregosAI::Reset(), boss_archimonde::Reset(), npc_hyjal_jaina::hyjalJainaAI::Reset(), npc_hyjal_thrall::hyjalThrallAI::Reset(), npc_hyjal_tyrande::hyjalTyrandeAI::Reset(), npc_hyjal_ground_trash::Reset(), npc_hyjal_gargoyle::Reset(), npc_hyjal_frost_wyrm::Reset(), boss_isalien::Reset(), npc_hivezara_stinger::Reset(), npc_obsidian_destroyer::Reset(), boss_bug_trio::Reset(), boss_ouro::Reset(), npc_anubisath_defender::Reset(), npc_vekniss_stinger::Reset(), npc_obsidian_eradicator::Reset(), npc_anubisath_warder::Reset(), npc_obsidian_nullifier::Reset(), npc_ahnqiraji_critter::Reset(), boss_razuvious_minion::boss_razuvious_minionAI::Reset(), boss_illidan_stormrage::Reset(), npc_akama_illidan::Reset(), npc_maiev_illidan::Reset(), boss_high_nethermancer_zerevor::Reset(), boss_essence_of_suffering::boss_essence_of_sufferingAI::Reset(), boss_essence_of_desire::boss_essence_of_desireAI::Reset(), boss_essence_of_anger::boss_essence_of_angerAI::Reset(), npc_akama_shade::Reset(), npc_creature_generator_akama::Reset(), boss_doomlord_kazzak::boss_doomlordkazzakAI::Reset(), boss_doomwalker::Reset(), boss_fathomguard_sharkkis::Reset(), boss_fathomguard_tidalvess::Reset(), boss_fathomguard_caribdis::Reset(), boss_lady_vashj::Reset(), npc_tainted_elemental::Reset(), boss_hungarfen::Reset(), npc_underbat::Reset(), boss_olm_the_summoner::Reset(), boss_kiggler_the_crazed::Reset(), boss_blindeye_the_seer::Reset(), boss_krosh_firehand::Reset(), boss_vazruden::Reset(), boss_magtheridon::Reset(), boss_alar::Reset(), boss_high_astromancer_solarian::Reset(), npc_lord_sanguinar::Reset(), npc_capernian::Reset(), npc_telonicus::Reset(), npc_thaladred::Reset(), npc_raging_flames::Reset(), npc_enslaved_netherwing_drake::Reset(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::ResetRajaxxWaves(), boss_illidan_stormrage::ScheduleAbilities(), npc_dream_fog::npc_dream_fogAI::ScheduleEvents(), boss_the_lurker_below::SchedulerPhaseOne(), boss_the_lurker_below::SchedulerPhaseTwo(), npc_shattered_hand_scout::SetData(), npc_warchief_portal::SetData(), World::ShutdownServ(), npc_giant_claw_tentacle::Submerge(), and boss_cthun::SummonedCreatureDies().

◆ CancelGroup()

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!

54{
55 _task_holder.RemoveIf([group](TaskContainer const & task) -> bool
56 {
57 return task->IsInGroup(group);
58 });
59 return *this;
60}
std::shared_ptr< Task > TaskContainer
Definition: TaskScheduler.h:118
void RemoveIf(std::function< bool(TaskContainer const &)> const &filter)
Definition: TaskScheduler.cpp:149

References _task_holder, and TaskScheduler::TaskQueue::RemoveIf().

Referenced by boss_marli::_schedulePhaseSpider(), boss_marli::_schedulePhaseTroll(), TaskContext::CancelGroup(), CancelGroupsOf(), boss_mor_grayhoof::DamageTaken(), boss_ouro::DamageTaken(), boss_shade_of_aran::DamageTaken(), boss_leotheras_the_blind::DemonTime(), boss_julianne::DoAction(), boss_romulo::DoAction(), boss_twinemperorsAI::DoAction(), boss_razuvious_minion::boss_razuvious_minionAI::DoAction(), boss_fathomguard_tidalvess::DoAction(), boss_magtheridon::DoAction(), boss_grand_warlock_nethekurse::DoAction(), boss_nazan::DoAction(), boss_halazzi::EnterPhase(), boss_venoxis::JustEngagedWith(), boss_moroes::JustEngagedWith(), boss_razuvious_minion::boss_razuvious_minionAI::JustEngagedWith(), boss_supremus::JustEngagedWith(), boss_nalorakk::MoveInLineOfSight(), boss_shade_of_aran::OnPowerUpdate(), boss_jeklik::PathEndReached(), boss_malchezaar::Reset(), boss_ayamiss::Reset(), boss_leotheras_the_blind::Reset(), boss_nightbane::ScheduleLand(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::ScheduleNextPortal(), boss_supremus::SchedulePhase(), instance_hyjal::instance_mount_hyjal_InstanceMapScript::SetData(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::SetData(), boss_hydross_the_unstable::SetForm(), boss_nalorakk::ShapeShift(), boss_julianne::SpellHit(), boss_ouro::Submerge(), boss_netherspite::SwitchToBanishPhase(), boss_netherspite::SwitchToPortalPhase(), and boss_nightbane::TriggerHealthTakeOff().

◆ CancelGroupsOf()

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}"

63{
64 std::for_each(groups.begin(), groups.end(),
65 std::bind(&TaskScheduler::CancelGroup, this, std::placeholders::_1));
66
67 return *this;
68}
TaskScheduler & CancelGroup(group_t const group)
Definition: TaskScheduler.cpp:53

References CancelGroup().

Referenced by TaskContext::CancelGroupsOf().

◆ ClearValidator()

TaskScheduler & TaskScheduler::ClearValidator ( )

Clears the validator which is asked if tasks are allowed to be executed.

22{
24 return *this;
25}

References _predicate, and EmptyValidator().

Referenced by boss_high_botanist_freywinn::JustEngagedWith().

◆ DelayAll() [1/2]

◆ DelayAll() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskScheduler & TaskScheduler::DelayAll ( std::chrono::duration< _RepLeft, _PeriodLeft > const &  min,
std::chrono::duration< _RepRight, _PeriodRight > const &  max 
)
inline

Delays all tasks with a random duration between min and max.

294 {
295 return DelayAll(RandomDurationBetween(min, max));
296 }
TaskScheduler & DelayAll(std::chrono::duration< _Rep, _Period > const &duration)
Delays all tasks with the given duration.
Definition: TaskScheduler.h:280
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:400

References DelayAll(), and RandomDurationBetween().

◆ DelayGroup() [1/2]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::DelayGroup ( group_t const  group,
std::chrono::duration< _Rep, _Period > const &  duration 
)
inline

Delays all tasks of a group with the given duration.

301 {
302 _task_holder.ModifyIf([&duration, group](TaskContainer const & task) -> bool
303 {
304 if (task->IsInGroup(group))
305 {
306 task->_end += duration;
307 return true;
308 }
309 else
310 {
311 return false;
312 }
313 });
314 return *this;
315 }

References _task_holder, and TaskScheduler::TaskQueue::ModifyIf().

Referenced by boss_mor_grayhoof::DamageTaken(), DelayGroup(), boss_archimonde::JustEngagedWith(), boss_kelidan_the_breaker::JustEngagedWith(), boss_gurtogg_bloodboil::JustEngagedWith(), boss_void_reaver::JustEngagedWith(), and boss_razuvious::boss_razuviousAI::ScheduleInteractWithDeathKnight().

◆ DelayGroup() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskScheduler & TaskScheduler::DelayGroup ( group_t const  group,
std::chrono::duration< _RepLeft, _PeriodLeft > const &  min,
std::chrono::duration< _RepRight, _PeriodRight > const &  max 
)
inline

Delays all tasks of a group with a random duration between min and max.

322 {
323 return DelayGroup(group, RandomDurationBetween(min, max));
324 }
TaskScheduler & DelayGroup(group_t const group, std::chrono::duration< _Rep, _Period > const &duration)
Delays all tasks of a group with the given duration.
Definition: TaskScheduler.h:300

References DelayGroup(), and RandomDurationBetween().

◆ Dispatch()

void TaskScheduler::Dispatch ( success_t const &  callback)
private

Dispatch remaining tasks.

77{
78 // If the validation failed abort the dispatching here.
79 if (!_predicate())
80 {
81 return;
82 }
83
84 // Process all asyncs
85 while (!_asyncHolder.empty())
86 {
87 _asyncHolder.front()();
88 _asyncHolder.pop();
89
90 // If the validation failed abort the dispatching here.
91 if (!_predicate())
92 {
93 return;
94 }
95 }
96
97 while (!_task_holder.IsEmpty())
98 {
99 if (_task_holder.First()->_end > _now)
100 {
101 break;
102 }
103
104 // Perfect forward the context to the handler
105 // Use weak references to catch destruction before callbacks.
106 TaskContext context(_task_holder.Pop(), std::weak_ptr<TaskScheduler>(self_reference));
107
108 // Invoke the context
109 context.Invoke();
110
111 // If the validation failed abort the dispatching here.
112 if (!_predicate())
113 {
114 return;
115 }
116 }
117
118 // On finish call the final callback
119 callback();
120}
bool IsEmpty() const
Definition: TaskScheduler.cpp:192
TaskContainer Pop()
Pops the task out of the container.
Definition: TaskScheduler.cpp:132
TaskContainer const & First() const
Definition: TaskScheduler.cpp:139
Definition: TaskScheduler.h:415

References _asyncHolder, _now, _predicate, _task_holder, TaskScheduler::TaskQueue::First(), TaskContext::Invoke(), TaskScheduler::TaskQueue::IsEmpty(), TaskScheduler::TaskQueue::Pop(), and self_reference.

Referenced by TaskContext::Async(), TaskContext::CancelAll(), TaskContext::CancelGroup(), TaskContext::CancelGroupsOf(), and Update().

◆ EmptyCallback()

static void TaskScheduler::EmptyCallback ( )
inlinestaticprivate
177 {
178 }

◆ EmptyValidator()

static bool TaskScheduler::EmptyValidator ( )
inlinestaticprivate
172 {
173 return true;
174 }

Referenced by ClearValidator().

◆ InsertTask()

TaskScheduler & TaskScheduler::InsertTask ( TaskContainer  task)
private

Insert a new task to the enqueued tasks.

71{
72 _task_holder.Push(std::move(task));
73 return *this;
74}
void Push(TaskContainer &&task)
Definition: TaskScheduler.cpp:127

References _task_holder, and TaskScheduler::TaskQueue::Push().

Referenced by TaskContext::Repeat(), and ScheduleAt().

◆ IsGroupScheduled()

bool TaskScheduler::IsGroupScheduled ( group_t const  group)

Check if the group exists and is currently scheduled.

123{
124 return _task_holder.IsGroupQueued(group);
125}
bool IsGroupQueued(group_t const group)
Check if the group exists and is currently scheduled.
Definition: TaskScheduler.cpp:179

References _task_holder, and TaskScheduler::TaskQueue::IsGroupQueued().

Referenced by boss_murmur::JustEngagedWith(), and instance_magisters_terrace::instance_magisters_terrace_InstanceMapScript::ProcessEvent().

◆ operator=() [1/2]

TaskScheduler & TaskScheduler::operator= ( TaskScheduler &&  )
delete

◆ operator=() [2/2]

TaskScheduler & TaskScheduler::operator= ( TaskScheduler const &  )
delete

◆ RandomDurationBetween()

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
static std::chrono::milliseconds TaskScheduler::RandomDurationBetween ( std::chrono::duration< _RepLeft, _PeriodLeft > const &  min,
std::chrono::duration< _RepRight, _PeriodRight > const &  max 
)
inlinestaticprivate
402 {
403 auto const milli_min = std::chrono::duration_cast<std::chrono::milliseconds>(min);
404 auto const milli_max = std::chrono::duration_cast<std::chrono::milliseconds>(max);
405
406 // TC specific: use SFMT URandom
407 return std::chrono::milliseconds(urand(uint32(milli_min.count()), uint32(milli_max.count())));
408 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
std::uint32_t uint32
Definition: Define.h:107

References urand().

Referenced by DelayAll(), TaskContext::DelayAll(), DelayGroup(), TaskContext::DelayGroup(), TaskContext::Repeat(), RescheduleAll(), TaskContext::RescheduleAll(), RescheduleGroup(), TaskContext::RescheduleGroup(), Schedule(), and TaskContext::Schedule().

◆ RescheduleAll() [1/2]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::RescheduleAll ( std::chrono::duration< _Rep, _Period > const &  duration)
inline

Reschedule all tasks with a given duration.

329 {
330 auto const end = _now + duration;
331 _task_holder.ModifyIf([end](TaskContainer const & task) -> bool
332 {
333 task->_end = end;
334 return true;
335 });
336 return *this;
337 }

References _now, _task_holder, and TaskScheduler::TaskQueue::ModifyIf().

Referenced by TaskContext::RescheduleAll(), and RescheduleAll().

◆ RescheduleAll() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskScheduler & TaskScheduler::RescheduleAll ( std::chrono::duration< _RepLeft, _PeriodLeft > const &  min,
std::chrono::duration< _RepRight, _PeriodRight > const &  max 
)
inline

Reschedule all tasks with a random duration between min and max.

343 {
344 return RescheduleAll(RandomDurationBetween(min, max));
345 }
TaskScheduler & RescheduleAll(std::chrono::duration< _Rep, _Period > const &duration)
Reschedule all tasks with a given duration.
Definition: TaskScheduler.h:328

References RandomDurationBetween(), and RescheduleAll().

◆ RescheduleGroup() [1/2]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::RescheduleGroup ( group_t const  group,
std::chrono::duration< _Rep, _Period > const &  duration 
)
inline

Reschedule all tasks of a group with the given duration.

350 {
351 auto const end = _now + duration;
352 _task_holder.ModifyIf([end, group](TaskContainer const & task) -> bool
353 {
354 if (task->IsInGroup(group))
355 {
356 task->_end = end;
357 return true;
358 }
359 else
360 {
361 return false;
362 }
363 });
364 return *this;
365 }

References _now, _task_holder, and TaskScheduler::TaskQueue::ModifyIf().

Referenced by RescheduleGroup(), and boss_the_lurker_below::SchedulerPhaseOne().

◆ RescheduleGroup() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskScheduler & TaskScheduler::RescheduleGroup ( group_t const  group,
std::chrono::duration< _RepLeft, _PeriodLeft > const &  min,
std::chrono::duration< _RepRight, _PeriodRight > const &  max 
)
inline

Reschedule all tasks of a group with a random duration between min and max.

372 {
373 return RescheduleGroup(group, RandomDurationBetween(min, max));
374 }
TaskScheduler & RescheduleGroup(group_t const group, std::chrono::duration< _Rep, _Period > const &duration)
Reschedule all tasks of a group with the given duration.
Definition: TaskScheduler.h:349

References RandomDurationBetween(), and RescheduleGroup().

◆ Schedule() [1/4]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::Schedule ( std::chrono::duration< _Rep, _Period > const &  time,
group_t const  group,
task_handler_t const &  task 
)
inline

Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!

240 {
241 return ScheduleAt(_now, time, group, task);
242 }
TaskScheduler & ScheduleAt(timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition: TaskScheduler.h:381

References _now, and ScheduleAt().

◆ Schedule() [2/4]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::Schedule ( std::chrono::duration< _Rep, _Period > const &  time,
task_handler_t const &  task 
)
inline

Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!

231 {
232 return ScheduleAt(_now, time, task);
233 }

References _now, and ScheduleAt().

Referenced by boss_marli::_schedulePhaseSpider(), boss_marli::_schedulePhaseTroll(), boss_high_nethermancer_zerevor::CastDampenMagicIfPossible(), boss_mor_grayhoof::CastRandomSpell(), boss_thekal::CheckPhaseTransition(), boss_mor_grayhoof::DamageTaken(), boss_isalien::DamageTaken(), boss_ouro::DamageTaken(), boss_freya::boss_freyaAI::DamageTaken(), boss_hodir::boss_hodirAI::DamageTaken(), boss_viscidus::DamageTaken(), boss_shade_of_aran::DamageTaken(), boss_leotheras_the_blind::DemonTime(), boss_nightbane::DoAction(), boss_dorothee::DoAction(), boss_roar::DoAction(), boss_strawman::DoAction(), boss_tinhead::DoAction(), boss_apothecary_hummel::boss_apothecary_hummelAI::DoAction(), boss_twinemperorsAI::DoAction(), npc_thrall_warchief::npc_thrall_warchiefAI::DoAction(), boss_broggok::DoAction(), boss_magtheridon::DoAction(), instance_karazhan::instance_karazhan_InstanceMapScript::DoAction(), boss_leotheras_the_blind::DoAction(), boss_pathaleon_the_calculator::DoAction(), npc_ulduar_keeper::npc_ulduar_keeperAI::DoAction(), npc_midsummer_ribbon_pole_target::DoFireworkChecks(), boss_leotheras_the_blind::ElfTime(), boss_ouro::Emerge(), boss_jindo::EnterEvadeMode(), boss_halazzi::EnterPhase(), boss_warbringer_omrogg::HandleHeadTalk(), boss_glob_of_viscidus::InitializeAI(), npc_rancid_mushroom::InitializeAI(), npc_ahune_ice_spear_bunny::InitializeAI(), npc_underbog_mushroom::InitializeAI(), boss_moroes::InitializeGuests(), go_firework_show::InitShow(), boss_grand_warlock_nethekurse::IntroRP(), npc_corrupted_totem::IsSummonedBy(), boss_kormok::IsSummonedBy(), boss_jarien::IsSummonedBy(), boss_sothos::IsSummonedBy(), npc_anzu_spirit::IsSummonedBy(), npc_parasitic_shadowfiend::IsSummonedBy(), npc_supremus_punch_invisible_stalker::IsSummonedBy(), npc_raging_flames::IsSummonedBy(), npc_drakonid_spawner::IsSummonedBy(), boss_attumen::IsSummonedBy(), npc_inner_demon::IsSummonedBy(), boss_mor_grayhoof::JustEngagedWith(), npc_lava_spawn::JustEngagedWith(), boss_malchezaar::JustEngagedWith(), npc_malchezaar_axe::JustEngagedWith(), boss_servant_quarters::JustEngagedWith(), boss_shade_of_aran::JustEngagedWith(), npc_kilrek::JustEngagedWith(), boss_terestian_illhoof::JustEngagedWith(), boss_dorothee::JustEngagedWith(), npc_tito::JustEngagedWith(), boss_roar::JustEngagedWith(), boss_strawman::JustEngagedWith(), boss_tinhead::JustEngagedWith(), boss_crone::JustEngagedWith(), npc_cyclone::JustEngagedWith(), boss_bigbadwolf::JustEngagedWith(), boss_kormok::JustEngagedWith(), boss_baroness_anastari::boss_baroness_anastariAI::JustEngagedWith(), boss_jarien::JustEngagedWith(), boss_sothos::JustEngagedWith(), boss_twilight_corrupter::JustEngagedWith(), npc_vilebranch_speaker::JustEngagedWith(), npc_spawn_of_marli::JustEngagedWith(), boss_thekal::JustEngagedWith(), npc_zealot_lorkhan::JustEngagedWith(), npc_zealot_zath::JustEngagedWith(), boss_venoxis::JustEngagedWith(), npc_hallows_end_soh::JustEngagedWith(), boss_azuregos::boss_azuregosAI::JustEngagedWith(), npc_hyjal_jaina::hyjalJainaAI::JustEngagedWith(), npc_hyjal_thrall::hyjalThrallAI::JustEngagedWith(), npc_hyjal_tyrande::hyjalTyrandeAI::JustEngagedWith(), npc_hyjal_ground_trash::JustEngagedWith(), npc_hyjal_gargoyle::JustEngagedWith(), npc_hyjal_frost_wyrm::JustEngagedWith(), boss_epoch_hunter::JustEngagedWith(), boss_lieutenant_drake::JustEngagedWith(), boss_aeonus::JustEngagedWith(), boss_chrono_lord_deja::JustEngagedWith(), boss_temporus::JustEngagedWith(), boss_isalien::JustEngagedWith(), npc_anubisath_guardian::JustEngagedWith(), npc_obsidian_destroyer::JustEngagedWith(), npc_eye_tentacle::JustEngagedWith(), npc_claw_tentacle::JustEngagedWith(), npc_dirt_mound::JustEngagedWith(), npc_anubisath_defender::JustEngagedWith(), npc_obsidian_eradicator::JustEngagedWith(), npc_anubisath_warder::JustEngagedWith(), npc_obsidian_nullifier::JustEngagedWith(), npc_icc_spire_frostwyrm::JustEngagedWith(), boss_yoggsaron_keeper::JustEngagedWith(), boss_exarch_maladaar::JustEngagedWith(), boss_shirrak_the_dead_watcher::JustEngagedWith(), boss_nexusprince_shaffar::JustEngagedWith(), npc_yor::JustEngagedWith(), boss_tavarok::JustEngagedWith(), boss_anzu::JustEngagedWith(), boss_darkweaver_syth::JustEngagedWith(), boss_talon_king_ikiss::JustEngagedWith(), boss_ambassador_hellmaw::JustEngagedWith(), boss_blackheart_the_inciter::JustEngagedWith(), boss_grandmaster_vorpil::JustEngagedWith(), boss_essence_of_desire::boss_essence_of_desireAI::JustEngagedWith(), boss_doomlord_kazzak::boss_doomlordkazzakAI::JustEngagedWith(), boss_doomwalker::JustEngagedWith(), npc_tainted_elemental::JustEngagedWith(), boss_mennu_the_betrayer::JustEngagedWith(), boss_quagmirran::JustEngagedWith(), boss_rokmar_the_crackler::JustEngagedWith(), boss_hydromancer_thespia::JustEngagedWith(), boss_mekgineer_steamrigger::JustEngagedWith(), boss_warlord_kalithresh::JustEngagedWith(), boss_ghazan::JustEngagedWith(), boss_hungarfen::JustEngagedWith(), boss_swamplord_muselek::JustEngagedWith(), boss_the_black_stalker::JustEngagedWith(), npc_underbat::JustEngagedWith(), boss_gruul::JustEngagedWith(), boss_high_king_maulgar::JustEngagedWith(), boss_olm_the_summoner::JustEngagedWith(), boss_kiggler_the_crazed::JustEngagedWith(), boss_blindeye_the_seer::JustEngagedWith(), boss_krosh_firehand::JustEngagedWith(), boss_kelidan_the_breaker::JustEngagedWith(), boss_the_maker::JustEngagedWith(), boss_omor_the_unscarred::JustEngagedWith(), boss_nazan::JustEngagedWith(), boss_vazruden::JustEngagedWith(), boss_watchkeeper_gargolmar::JustEngagedWith(), boss_dalliah_the_doomsayer::JustEngagedWith(), boss_harbinger_skyriss::JustEngagedWith(), boss_zereketh_the_unbound::JustEngagedWith(), boss_high_botanist_freywinn::JustEngagedWith(), boss_thorngrin_the_tender::JustEngagedWith(), boss_warp_splinter::JustEngagedWith(), boss_gatewatcher_gyrokill::JustEngagedWith(), boss_gatewatcher_iron_hand::JustEngagedWith(), boss_mechano_lord_capacitus::JustEngagedWith(), boss_nethermancer_sepethrea::JustEngagedWith(), boss_pathaleon_the_calculator::JustEngagedWith(), boss_curator::JustEngagedWith(), boss_maiden_of_virtue::JustEngagedWith(), boss_midnight::JustEngagedWith(), boss_moroes::JustEngagedWith(), boss_netherspite::JustEngagedWith(), boss_nalorakk::JustEngagedWith(), npc_batrider::JustEngagedWith(), npc_ohgan::npc_ohganAI::JustEngagedWith(), boss_marli::JustEngagedWith(), boss_anetheron::JustEngagedWith(), boss_azgalor::JustEngagedWith(), boss_kazrogal::JustEngagedWith(), boss_rage_winterchill::JustEngagedWith(), boss_kurinnaxx::JustEngagedWith(), npc_hivezara_stinger::JustEngagedWith(), boss_kri::JustEngagedWith(), boss_vem::JustEngagedWith(), boss_yauj::JustEngagedWith(), boss_fankriss::JustEngagedWith(), boss_twinemperorsAI::JustEngagedWith(), boss_veknilash::JustEngagedWith(), boss_veklor::JustEngagedWith(), npc_vekniss_stinger::JustEngagedWith(), boss_murmur::JustEngagedWith(), boss_gurtogg_bloodboil::JustEngagedWith(), boss_supremus::JustEngagedWith(), boss_fathomlord_karathress::JustEngagedWith(), boss_fathomguard_sharkkis::JustEngagedWith(), boss_fathomguard_tidalvess::JustEngagedWith(), boss_fathomguard_caribdis::JustEngagedWith(), boss_hydross_the_unstable::JustEngagedWith(), boss_morogrim_tidewalker::JustEngagedWith(), boss_magtheridon::JustEngagedWith(), boss_grand_warlock_nethekurse::JustEngagedWith(), boss_porung::JustEngagedWith(), boss_warchief_kargath_bladefist::JustEngagedWith(), boss_alar::JustEngagedWith(), boss_high_astromancer_solarian::JustEngagedWith(), boss_void_reaver::JustEngagedWith(), boss_fathomlord_karathress::KilledUnit(), boss_hydross_the_unstable::KilledUnit(), boss_lady_vashj::KilledUnit(), boss_morogrim_tidewalker::KilledUnit(), boss_gruul::KilledUnit(), boss_high_king_maulgar::KilledUnit(), boss_omor_the_unscarred::KilledUnit(), boss_vazruden::KilledUnit(), boss_watchkeeper_gargolmar::KilledUnit(), boss_magtheridon::KilledUnit(), boss_void_reaver::KilledUnit(), boss_moroes::KilledUnit(), boss_anetheron::KilledUnit(), boss_azgalor::KilledUnit(), boss_kazrogal::KilledUnit(), boss_rage_winterchill::KilledUnit(), npc_midsummer_ribbon_pole_target::LocateRibbonPole(), boss_nalorakk::MoveInLineOfSight(), npc_ulduar_snow_mound::MoveInLineOfSight(), boss_nightbane::MovementInform(), boss_ayamiss::MovementInform(), boss_bug_trio::MovementInform(), boss_lady_vashj::MovementInform(), boss_nazan::MovementInform(), boss_servant_quarters::MovementInform(), npc_shattered_hand_scout::MovementInform(), boss_warchief_kargath_bladefist::MovementInform(), npc_midsummer_bonfire::npc_midsummer_bonfire(), npc_midsummer_ribbon_pole_target::npc_midsummer_ribbon_pole_target(), boss_high_nethermancer_zerevor::OnAuraRemove(), boss_shade_of_aran::OnPowerUpdate(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::OnUnitDeath(), instance_temple_of_ahnqiraj::instance_temple_of_ahnqiraj_InstanceMapScript::OnUnitDeath(), boss_nightbane::PathEndReached(), boss_jeklik::PathEndReached(), instance_magisters_terrace::instance_magisters_terrace_InstanceMapScript::ProcessEvent(), boss_malchezaar::Reset(), boss_julianne::Reset(), npc_apothecary_baxter::Reset(), boss_thekal::Reset(), npc_zealot_lorkhan::Reset(), npc_zealot_zath::Reset(), go_direbrew_mole_machine::go_direbrew_mole_machineAI::Reset(), go_sand_trap::Reset(), npc_eye_tentacle::Reset(), npc_claw_tentacle::Reset(), npc_giant_claw_tentacle::Reset(), npc_giant_eye_tentacle::Reset(), npc_ahnqiraji_critter::Reset(), boss_kologarn_pit_kill_bunny::Reset(), npc_ulduar_keeper::npc_ulduar_keeperAI::Reset(), npc_cosmetic_toy_plane::Reset(), boss_exarch_maladaar::Reset(), npc_stolen_soul::Reset(), boss_talon_king_ikiss::Reset(), npc_voidtraveler::Reset(), npc_ashtongue_channeler::Reset(), boss_leotheras_the_blind::Reset(), go_ahune_ice_spear::Reset(), boss_hungarfen::Reset(), boss_high_king_maulgar::Reset(), boss_omor_the_unscarred::Reset(), boss_watchkeeper_gargolmar::Reset(), boss_magtheridon::Reset(), npc_target_trigger::Reset(), boss_high_astromancer_solarian::Reset(), npc_injured_patient::npc_injured_patientAI::Reset(), Schedule(), boss_illidan_stormrage::ScheduleAbilities(), boss_razuvious_minion::boss_razuvious_minionAI::ScheduleAttackDummy(), boss_julianne::ScheduleCombat(), boss_romulo::ScheduleCombat(), boss_magtheridon::ScheduleCombatEvents(), Map::ScheduleCreatureRespawn(), npc_dream_fog::npc_dream_fogAI::ScheduleEvents(), boss_nightbane::ScheduleFly(), boss_nightbane::ScheduleGround(), boss_razuvious::boss_razuviousAI::ScheduleInteractWithDeathKnight(), boss_nightbane::ScheduleLand(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::ScheduleNextPortal(), boss_supremus::SchedulePhase(), boss_baroness_anastari::boss_baroness_anastariAI::SchedulePossession(), boss_commander_sarannis::ScheduleReinforcements(), boss_fathomguard_tidalvess::ScheduleRemoval(), boss_razuvious::boss_razuviousAI::ScheduleRP(), boss_the_lurker_below::SchedulerPhaseOne(), boss_the_lurker_below::SchedulerPhaseTwo(), boss_lady_vashj::ScheduleSpells(), npc_giant_claw_tentacle::ScheduleTasks(), boss_attumen::ScheduleTasks(), boss_ayamiss::ScheduleTasks(), boss_cthun::ScheduleTasks(), boss_laj::ScheduleTasks(), ScriptedAI::ScheduleTimedEvent(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::SetBossState(), boss_grand_warlock_nethekurse::SetData(), instance_hyjal::instance_mount_hyjal_InstanceMapScript::SetData(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::SetData(), instance_ulduar::instance_ulduar_InstanceMapScript::SetData(), npc_warchief_portal::SetData(), boss_thekal::SetData(), boss_hydross_the_unstable::SetForm(), boss_nalorakk::ShapeShift(), World::ShutdownServ(), npc_netherspite_infernal::SpellHit(), boss_terestian_illhoof::SpellHit(), boss_julianne::SpellHit(), npc_enslaved_netherwing_drake::SpellHit(), go_firework_show::StartShow(), npc_giant_claw_tentacle::Submerge(), boss_cthun::SummonedCreatureDies(), npc_drakonid_spawner::SummonedCreatureDies(), boss_warchief_kargath_bladefist::SummonedCreatureDies(), boss_netherspite::SwitchToBanishPhase(), and boss_netherspite::SwitchToPortalPhase().

◆ Schedule() [3/4]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskScheduler & 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 
)
inline

Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Schedule instead!

259 {
260 return Schedule(RandomDurationBetween(min, max), group, task);
261 }
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition: TaskScheduler.h:229

References RandomDurationBetween(), and Schedule().

◆ Schedule() [4/4]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskScheduler & TaskScheduler::Schedule ( std::chrono::duration< _RepLeft, _PeriodLeft > const &  min,
std::chrono::duration< _RepRight, _PeriodRight > const &  max,
task_handler_t const &  task 
)
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!

249 {
250 return Schedule(RandomDurationBetween(min, max), task);
251 }

References RandomDurationBetween(), and Schedule().

◆ ScheduleAt() [1/2]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::ScheduleAt ( timepoint_t const &  end,
std::chrono::duration< _Rep, _Period > const &  time,
group_t const  group,
task_handler_t const &  task 
)
inlineprivate

Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::schedule instead!

393 {
394 static repeated_t const DEFAULT_REPEATED = 0;
395 return InsertTask(TaskContainer(new Task(end + time, time, group, DEFAULT_REPEATED, task)));
396 }
TaskScheduler & InsertTask(TaskContainer task)
Insert a new task to the enqueued tasks.
Definition: TaskScheduler.cpp:70
uint32 repeated_t
Definition: TaskScheduler.h:56

References InsertTask().

◆ ScheduleAt() [2/2]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::ScheduleAt ( timepoint_t const &  end,
std::chrono::duration< _Rep, _Period > const &  time,
task_handler_t const &  task 
)
inlineprivate
383 {
384 return InsertTask(TaskContainer(new Task(end + time, time, task)));
385 }

References InsertTask().

Referenced by Schedule(), and TaskContext::Schedule().

◆ SetValidator()

template<typename P >
TaskScheduler & TaskScheduler::SetValidator ( P &&  predicate)
inline

Sets a validator which is asked if tasks are allowed to be executed.

195 {
196 _predicate = std::forward<P>(predicate);
197 return *this;
198 }

References _predicate.

Referenced by boss_alar::boss_alar(), boss_anetheron::boss_anetheron(), boss_anzu::boss_anzu(), boss_apothecary_hummel::boss_apothecary_hummelAI::boss_apothecary_hummelAI(), boss_archimonde::boss_archimonde(), boss_azgalor::boss_azgalor(), boss_azuregos::boss_azuregosAI::boss_azuregosAI(), boss_balinda::boss_balinda(), boss_bigbadwolf::boss_bigbadwolf(), boss_blackheart_the_inciter::boss_blackheart_the_inciter(), boss_blindeye_the_seer::boss_blindeye_the_seer(), boss_captain_skarloc::boss_captain_skarloc(), boss_curator::boss_curator(), boss_darkweaver_syth::boss_darkweaver_syth(), boss_dorothee::boss_dorothee(), boss_exarch_maladaar::boss_exarch_maladaar(), boss_fathomguard_caribdis::boss_fathomguard_caribdis(), boss_fathomguard_sharkkis::boss_fathomguard_sharkkis(), boss_fathomguard_tidalvess::boss_fathomguard_tidalvess(), boss_ghazan::boss_ghazan(), boss_grand_warlock_nethekurse::boss_grand_warlock_nethekurse(), boss_halazzi::boss_halazzi(), boss_high_astromancer_solarian::boss_high_astromancer_solarian(), boss_high_king_maulgar::boss_high_king_maulgar(), boss_jarien::boss_jarien(), boss_kazrogal::boss_kazrogal(), boss_kelidan_the_breaker::boss_kelidan_the_breaker(), boss_kiggler_the_crazed::boss_kiggler_the_crazed(), boss_krosh_firehand::boss_krosh_firehand(), boss_lady_vashj::boss_lady_vashj(), boss_magtheridon::boss_magtheridon(), boss_maiden_of_virtue::boss_maiden_of_virtue(), boss_mekgineer_steamrigger::boss_mekgineer_steamrigger(), boss_mennu_the_betrayer::boss_mennu_the_betrayer(), boss_mor_grayhoof::boss_mor_grayhoof(), boss_moroes::boss_moroes(), boss_morogrim_tidewalker::boss_morogrim_tidewalker(), boss_murmur::boss_murmur(), boss_nazan::boss_nazan(), boss_nexusprince_shaffar::boss_nexusprince_shaffar(), boss_olm_the_summoner::boss_olm_the_summoner(), boss_omor_the_unscarred::boss_omor_the_unscarred(), boss_pandemonius::boss_pandemonius(), boss_quagmirran::boss_quagmirran(), boss_rage_winterchill::boss_rage_winterchill(), boss_roar::boss_roar(), boss_rokmar_the_crackler::boss_rokmar_the_crackler(), boss_shirrak_the_dead_watcher::boss_shirrak_the_dead_watcher(), boss_sothos::boss_sothos(), boss_strawman::boss_strawman(), boss_supremus::boss_supremus(), boss_swamplord_muselek::boss_swamplord_muselek(), boss_talon_king_ikiss::boss_talon_king_ikiss(), boss_tavarok::boss_tavarok(), boss_terestian_illhoof::boss_terestian_illhoof(), boss_the_black_stalker::boss_the_black_stalker(), boss_the_maker::boss_the_maker(), boss_tinhead::boss_tinhead(), boss_vazruden::boss_vazruden(), boss_void_reaver::boss_void_reaver(), boss_warbringer_omrogg::boss_warbringer_omrogg(), boss_warchief_kargath_bladefist::boss_warchief_kargath_bladefist(), boss_watchkeeper_gargolmar::boss_watchkeeper_gargolmar(), BossAI::BossAI(), boss_venoxis::InitializeAI(), npc_coren_direbrew_sisters::JustEngagedWith(), npc_apothecary_baxter::npc_apothecary_baxter(), npc_batrider::npc_batrider(), npc_capernian::npc_capernian(), npc_hyjal_frost_wyrm::npc_hyjal_frost_wyrm(), npc_hyjal_gargoyle::npc_hyjal_gargoyle(), npc_hyjal_ground_trash::npc_hyjal_ground_trash(), npc_icc_spire_frostwyrm::npc_icc_spire_frostwyrm(), npc_inner_demon::npc_inner_demon(), npc_lord_sanguinar::npc_lord_sanguinar(), npc_telonicus::npc_telonicus(), npc_thaladred::npc_thaladred(), boss_kormok::Reset(), boss_baroness_anastari::boss_baroness_anastariAI::Reset(), npc_ohgan::npc_ohganAI::Reset(), boss_thekal::Reset(), npc_zealot_lorkhan::Reset(), npc_zealot_zath::Reset(), boss_isalien::Reset(), and npc_anubisath_guardian::Reset().

◆ Update() [1/3]

template<class _Rep , class _Period >
TaskScheduler & TaskScheduler::Update ( std::chrono::duration< _Rep, _Period > const &  difftime,
success_t const &  callback = EmptyCallback 
)
inline

Update the scheduler with a difftime. Calls the optional callback on successfully finish.

216 {
217 _now += difftime;
218 Dispatch(callback);
219 return *this;
220 }
void Dispatch(success_t const &callback)
Dispatch remaining tasks.
Definition: TaskScheduler.cpp:76

References _now, and Dispatch().

◆ Update() [2/3]

TaskScheduler & TaskScheduler::Update ( std::size_t const  milliseconds,
success_t const &  callback = EmptyCallback 
)

Update the scheduler with a difftime in ms. Calls the optional callback on successfully finish.

35{
36 return Update(std::chrono::milliseconds(milliseconds), callback);
37}
TaskScheduler & Update(success_t const &callback=EmptyCallback)
Definition: TaskScheduler.cpp:27

References Update().

◆ Update() [3/3]

TaskScheduler & TaskScheduler::Update ( success_t const &  callback = EmptyCallback)

Update the scheduler to the current time. Calls the optional callback on successfully finish.

28{
29 _now = clock_t::now();
30 Dispatch(callback);
31 return *this;
32}

References _now, and Dispatch().

Referenced by Map::Update(), Update(), World::Update(), InstanceScript::Update(), go_sand_trap::UpdateAI(), BossAI::UpdateAI(), boss_mor_grayhoof::UpdateAI(), npc_drakonid_spawner::UpdateAI(), npc_lava_spawn::UpdateAI(), boss_midnight::UpdateAI(), boss_moroes::UpdateAI(), boss_netherspite::UpdateAI(), boss_nightbane::UpdateAI(), npc_netherspite_infernal::UpdateAI(), npc_malchezaar_axe::UpdateAI(), boss_servant_quarters::UpdateAI(), npc_kilrek::UpdateAI(), boss_dorothee::UpdateAI(), npc_tito::UpdateAI(), boss_roar::UpdateAI(), boss_strawman::UpdateAI(), boss_tinhead::UpdateAI(), boss_crone::UpdateAI(), npc_cyclone::UpdateAI(), boss_bigbadwolf::UpdateAI(), boss_julianne::UpdateAI(), boss_romulo::UpdateAI(), boss_kormok::UpdateAI(), boss_apothecary_hummel::boss_apothecary_hummelAI::UpdateAI(), npc_apothecary_baxter::UpdateAI(), boss_baroness_anastari::boss_baroness_anastariAI::UpdateAI(), boss_jarien::UpdateAI(), boss_sothos::UpdateAI(), boss_twilight_corrupter::UpdateAI(), npc_halazzi_lynx::UpdateAI(), boss_nalorakk::UpdateAI(), boss_jindo::UpdateAI(), npc_healing_ward::UpdateAI(), npc_shade_of_jindo::UpdateAI(), npc_ohgan::npc_ohganAI::UpdateAI(), npc_vilebranch_speaker::UpdateAI(), npc_spawn_of_marli::UpdateAI(), boss_thekal::UpdateAI(), npc_zealot_lorkhan::UpdateAI(), npc_zealot_zath::UpdateAI(), npc_coren_direbrew_sisters::UpdateAI(), go_direbrew_mole_machine::go_direbrew_mole_machineAI::UpdateAI(), go_firework_show::UpdateAI(), npc_hallows_end_soh::UpdateAI(), npc_midsummer_ribbon_pole_target::UpdateAI(), boss_azuregos::boss_azuregosAI::UpdateAI(), npc_doomfire_spirit::UpdateAI(), npc_hyjal_jaina::hyjalJainaAI::UpdateAI(), npc_hyjal_thrall::hyjalThrallAI::UpdateAI(), npc_hyjal_tyrande::hyjalTyrandeAI::UpdateAI(), npc_hyjal_ground_trash::UpdateAI(), npc_hyjal_gargoyle::UpdateAI(), npc_hyjal_frost_wyrm::UpdateAI(), boss_lieutenant_drake::UpdateAI(), boss_isalien::UpdateAI(), npc_anubisath_guardian::UpdateAI(), npc_hivezara_stinger::UpdateAI(), npc_obsidian_destroyer::UpdateAI(), boss_bug_trio::UpdateAI(), boss_cthun::UpdateAI(), npc_eye_tentacle::UpdateAI(), npc_claw_tentacle::UpdateAI(), npc_giant_claw_tentacle::UpdateAI(), npc_giant_eye_tentacle::UpdateAI(), boss_ouro::UpdateAI(), npc_dirt_mound::UpdateAI(), boss_twinemperorsAI::UpdateAI(), boss_viscidus::UpdateAI(), boss_glob_of_viscidus::UpdateAI(), npc_anubisath_defender::UpdateAI(), npc_vekniss_stinger::UpdateAI(), npc_anubisath_warder::UpdateAI(), npc_icc_spire_frostwyrm::UpdateAI(), boss_razuvious_minion::boss_razuvious_minionAI::UpdateAI(), boss_freya::boss_freyaAI::UpdateAI(), boss_hodir::boss_hodirAI::UpdateAI(), boss_kologarn_pit_kill_bunny::UpdateAI(), boss_yoggsaron_keeper::UpdateAI(), npc_ulduar_keeper::npc_ulduar_keeperAI::UpdateAI(), npc_ulduar_snow_mound::UpdateAI(), npc_cosmetic_toy_plane::UpdateAI(), boss_exarch_maladaar::UpdateAI(), npc_stolen_soul::UpdateAI(), boss_nexusprince_shaffar::UpdateAI(), npc_yor::UpdateAI(), boss_anzu::UpdateAI(), boss_ambassador_hellmaw::UpdateAI(), boss_blackheart_the_inciter::UpdateAI(), npc_akama_illidan::UpdateAI(), npc_maiev_illidan::UpdateAI(), npc_parasitic_shadowfiend::UpdateAI(), npc_flame_of_azzinoth::UpdateAI(), boss_illidari_council::UpdateAI(), boss_high_nethermancer_zerevor::UpdateAI(), boss_reliquary_of_souls::boss_reliquary_of_soulsAI::UpdateAI(), boss_essence_of_suffering::boss_essence_of_sufferingAI::UpdateAI(), boss_essence_of_desire::boss_essence_of_desireAI::UpdateAI(), boss_essence_of_anger::boss_essence_of_angerAI::UpdateAI(), boss_shade_of_akama::UpdateAI(), npc_akama_shade::UpdateAI(), npc_creature_generator_akama::UpdateAI(), npc_ashtongue_channeler::UpdateAI(), npc_supremus_punch_invisible_stalker::UpdateAI(), boss_teron_gorefiend::UpdateAI(), boss_doomlord_kazzak::boss_doomlordkazzakAI::UpdateAI(), boss_doomwalker::UpdateAI(), boss_fathomguard_sharkkis::UpdateAI(), boss_fathomguard_tidalvess::UpdateAI(), boss_fathomguard_caribdis::UpdateAI(), boss_lady_vashj::UpdateAI(), npc_tainted_elemental::UpdateAI(), boss_leotheras_the_blind::UpdateAI(), npc_inner_demon::UpdateAI(), boss_the_lurker_below::UpdateAI(), npc_rancid_mushroom::UpdateAI(), npc_ahune_ice_spear_bunny::UpdateAI(), go_ahune_ice_spear::UpdateAI(), boss_ghazan::UpdateAI(), boss_hungarfen::UpdateAI(), npc_underbog_mushroom::UpdateAI(), boss_the_black_stalker::UpdateAI(), npc_underbat::UpdateAI(), boss_gruul::UpdateAI(), boss_high_king_maulgar::UpdateAI(), boss_olm_the_summoner::UpdateAI(), boss_kiggler_the_crazed::UpdateAI(), boss_blindeye_the_seer::UpdateAI(), boss_krosh_firehand::UpdateAI(), boss_the_maker::UpdateAI(), boss_omor_the_unscarred::UpdateAI(), boss_nazan::UpdateAI(), boss_vazruden::UpdateAI(), boss_watchkeeper_gargolmar::UpdateAI(), boss_magtheridon::UpdateAI(), npc_target_trigger::UpdateAI(), boss_grand_warlock_nethekurse::UpdateAI(), boss_warchief_kargath_bladefist::UpdateAI(), npc_warchief_portal::UpdateAI(), npc_lord_sanguinar::UpdateAI(), npc_capernian::UpdateAI(), npc_telonicus::UpdateAI(), npc_raging_flames::UpdateAI(), npc_dream_fog::npc_dream_fogAI::UpdateAI(), npc_injured_patient::npc_injured_patientAI::UpdateAI(), and npc_batrider::UpdateAI().

Friends And Related Function Documentation

◆ TaskContext

friend class TaskContext
friend

Member Data Documentation

◆ _asyncHolder

AsyncHolder TaskScheduler::_asyncHolder
private

Contains all asynchronous tasks which will be invoked at the next update tick.

Referenced by Async(), CancelAll(), and Dispatch().

◆ _now

timepoint_t TaskScheduler::_now
private

The current time point (now)

Referenced by Dispatch(), RescheduleAll(), RescheduleGroup(), Schedule(), and Update().

◆ _predicate

predicate_t TaskScheduler::_predicate
private

◆ _task_holder

TaskQueue TaskScheduler::_task_holder
private

◆ self_reference

std::shared_ptr<TaskScheduler> TaskScheduler::self_reference
private

Contains a self reference to track if this object was deleted or not.

Referenced by Dispatch().