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

#include "TaskScheduler.h"

Public Member Functions

 TaskContext ()
 
 TaskContext (TaskScheduler::TaskContainer &&task, std::weak_ptr< TaskScheduler > &&owner)
 
 TaskContext (TaskContext const &right)
 
 TaskContext (TaskContext &&right) noexcept
 
TaskContextoperator= (TaskContext const &right) noexcept
 
TaskContextoperator= (TaskContext &&right) noexcept
 
bool IsExpired () const
 Returns true if the owner was deallocated and this context has expired.
 
bool IsInGroup (TaskScheduler::group_t const group) const
 Returns true if the event is in the given group.
 
TaskContextSetGroup (TaskScheduler::group_t const group)
 Sets the event in the given group.
 
TaskContextClearGroup ()
 Removes the group from the event.
 
TaskScheduler::repeated_t GetRepeatCounter () const
 Returns the repeat counter which increases every time the task is repeated.
 
TaskScheduler::timepoint_t GetNextOccurrence () const
 
template<class _Rep , class _Period >
TaskContextRepeat (std::chrono::duration< _Rep, _Period > const &duration)
 
TaskContextRepeat ()
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContextRepeat (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
 
TaskContextAsync (std::function< void()> const &callable)
 
template<class _Rep , class _Period >
TaskContextSchedule (std::chrono::duration< _Rep, _Period > const &time, TaskScheduler::task_handler_t const &task)
 
template<class _Rep , class _Period >
TaskContextSchedule (std::chrono::duration< _Rep, _Period > const &time, TaskScheduler::group_t const group, TaskScheduler::task_handler_t const &task)
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContextSchedule (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max, TaskScheduler::task_handler_t const &task)
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContextSchedule (std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max, TaskScheduler::group_t const group, TaskScheduler::task_handler_t const &task)
 
TaskContextCancelAll ()
 Cancels all tasks from within the context.
 
TaskContextCancelGroup (TaskScheduler::group_t const group)
 Cancel all tasks of a single group from within the context.
 
TaskContextCancelGroupsOf (std::vector< TaskScheduler::group_t > const &groups)
 
template<class _Rep , class _Period >
TaskContextDelayAll (std::chrono::duration< _Rep, _Period > const &duration)
 Delays all tasks with the given duration from within the context.
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContextDelayAll (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 from within the context.
 
template<class _Rep , class _Period >
TaskContextDelayGroup (TaskScheduler::group_t const group, std::chrono::duration< _Rep, _Period > const &duration)
 Delays all tasks of a group with the given duration from within the context.
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContextDelayGroup (TaskScheduler::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 from within the context.
 
template<class _Rep , class _Period >
TaskContextRescheduleAll (std::chrono::duration< _Rep, _Period > const &duration)
 Reschedule all tasks with the given duration.
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContextRescheduleAll (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.
 
template<class _Rep , class _Period >
TaskContextRescheduleGroup (TaskScheduler::group_t const group, std::chrono::duration< _Rep, _Period > const &duration)
 Reschedule all tasks of a group with the given duration.
 
template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContextRescheduleGroup (TaskScheduler::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.
 

Private Member Functions

TaskContextDispatch (std::function< TaskScheduler &(TaskScheduler &)> const &apply)
 Dispatches an action safe on the TaskScheduler.
 
void AssertOnConsumed () const
 Asserts if the task was consumed already.
 
void Invoke ()
 Invokes the associated hook of the task.
 

Private Attributes

TaskScheduler::TaskContainer _task
 Associated task.
 
std::weak_ptr< TaskScheduler_owner
 Owner.
 
std::shared_ptr< bool > _consumed
 Marks the task as consumed.
 

Friends

class TaskScheduler
 

Detailed Description

Constructor & Destructor Documentation

◆ TaskContext() [1/4]

TaskContext::TaskContext ( )
inline
439 : _task(), _owner(), _consumed(std::make_shared<bool>(true)) { }
TaskScheduler::TaskContainer _task
Associated task.
Definition TaskScheduler.h:425
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition TaskScheduler.h:428
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition TaskScheduler.h:431

◆ TaskContext() [2/4]

TaskContext::TaskContext ( TaskScheduler::TaskContainer &&  task,
std::weak_ptr< TaskScheduler > &&  owner 
)
inlineexplicit
443 : _task(task), _owner(owner), _consumed(std::make_shared<bool>(false)) { }

◆ TaskContext() [3/4]

TaskContext::TaskContext ( TaskContext const &  right)
inline
447 : _task(right._task), _owner(right._owner), _consumed(right._consumed) { }

◆ TaskContext() [4/4]

TaskContext::TaskContext ( TaskContext &&  right)
inlinenoexcept
451 : _task(std::move(right._task)), _owner(std::move(right._owner)), _consumed(std::move(right._consumed)) { }

Member Function Documentation

◆ AssertOnConsumed()

void TaskContext::AssertOnConsumed ( ) const
private

Asserts if the task was consumed already.

274{
275 // This was adapted to TC to prevent static analysis tools from complaining.
276 // If you encounter this assertion check if you repeat a TaskContext more then 1 time!
277 ASSERT(!(*_consumed) && "Bad task logic, task context was consumed already!");
278}
#define ASSERT
Definition Errors.h:68

References ASSERT.

Referenced by Repeat().

◆ Async()

TaskContext & TaskContext::Async ( std::function< void()> const &  callable)

Schedule a callable function that is executed at the next update tick from within the context. Its safe to modify the TaskScheduler from within the callable.

254{
255 return Dispatch(std::bind(&TaskScheduler::Async, std::placeholders::_1, callable));
256}
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition TaskScheduler.cpp:211
TaskScheduler & Async(std::function< void()> const &callable)
Definition TaskScheduler.cpp:39

References TaskScheduler::Async(), and TaskScheduler::Dispatch().

◆ CancelAll()

TaskContext & TaskContext::CancelAll ( )

Cancels all tasks from within the context.

259{
260 return Dispatch(std::mem_fn(&TaskScheduler::CancelAll));
261}
TaskScheduler & CancelAll()
Definition TaskScheduler.cpp:45

References TaskScheduler::CancelAll(), and TaskScheduler::Dispatch().

◆ CancelGroup()

TaskContext & TaskContext::CancelGroup ( TaskScheduler::group_t const  group)

Cancel all tasks of a single group from within the context.

264{
265 return Dispatch(std::bind(&TaskScheduler::CancelGroup, std::placeholders::_1, group));
266}
TaskScheduler & CancelGroup(group_t const group)
Definition TaskScheduler.cpp:53

References TaskScheduler::CancelGroup(), and TaskScheduler::Dispatch().

Referenced by boss_warbringer_omrogg::ScheduleBurningPhase().

◆ CancelGroupsOf()

TaskContext & TaskContext::CancelGroupsOf ( std::vector< TaskScheduler::group_t > const &  groups)

Cancels all groups in the given std::vector from within the context. Hint: Use std::initializer_list for this: "{1, 2, 3, 4}"

269{
270 return Dispatch(std::bind(&TaskScheduler::CancelGroupsOf, std::placeholders::_1, std::cref(groups)));
271}
TaskScheduler & CancelGroupsOf(std::vector< group_t > const &groups)
Definition TaskScheduler.cpp:62

References TaskScheduler::CancelGroupsOf(), and TaskScheduler::Dispatch().

◆ ClearGroup()

TaskContext & TaskContext::ClearGroup ( )

Removes the group from the event.

238{
239 _task->_group = std::nullopt;
240 return *this;
241}

◆ DelayAll() [1/2]

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

Delays all tasks with the given duration from within the context.

594 {
595 return Dispatch(std::bind(&TaskScheduler::DelayAll<_Rep, _Period>, std::placeholders::_1, duration));
596 }

References Dispatch().

Referenced by DelayAll().

◆ DelayAll() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContext & TaskContext::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 from within the context.

602 {
604 }
TaskContext & DelayAll(std::chrono::duration< _Rep, _Period > const &duration)
Delays all tasks with the given duration from within the context.
Definition TaskScheduler.h:593
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition TaskScheduler.h:406

References DelayAll(), and TaskScheduler::RandomDurationBetween().

◆ DelayGroup() [1/2]

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

Delays all tasks of a group with the given duration from within the context.

609 {
610 return Dispatch(std::bind(&TaskScheduler::DelayGroup<_Rep, _Period>, std::placeholders::_1, group, duration));
611 }

References Dispatch().

Referenced by DelayGroup(), boss_rage_winterchill::JustEngagedWith(), and boss_pandemonius::JustEngagedWith().

◆ DelayGroup() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContext & TaskContext::DelayGroup ( TaskScheduler::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 from within the context.

618 {
619 return DelayGroup(group, TaskScheduler::RandomDurationBetween(min, max));
620 }
TaskContext & DelayGroup(TaskScheduler::group_t const group, std::chrono::duration< _Rep, _Period > const &duration)
Delays all tasks of a group with the given duration from within the context.
Definition TaskScheduler.h:608

References DelayGroup(), and TaskScheduler::RandomDurationBetween().

◆ Dispatch()

TaskContext & TaskContext::Dispatch ( std::function< TaskScheduler &(TaskScheduler &)> const &  apply)
private

Dispatches an action safe on the TaskScheduler.

212{
213 if (auto const owner = _owner.lock())
214 {
215 apply(*owner);
216 }
217
218 return *this;
219}
void apply(T *val)
Definition ByteConverter.h:40

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

◆ GetNextOccurrence()

TaskScheduler::timepoint_t TaskContext::GetNextOccurrence ( ) const
249{
250 return _task->_end;
251}

◆ GetRepeatCounter()

◆ Invoke()

void TaskContext::Invoke ( )
private

Invokes the associated hook of the task.

281{
282 _task->_task(*this);
283}

Referenced by TaskScheduler::Dispatch().

◆ IsExpired()

bool TaskContext::IsExpired ( ) const

Returns true if the owner was deallocated and this context has expired.

222{
223 return _owner.expired();
224}

◆ IsInGroup()

bool TaskContext::IsInGroup ( TaskScheduler::group_t const  group) const

Returns true if the event is in the given group.

227{
228 return _task->IsInGroup(group);
229}

◆ operator=() [1/2]

TaskContext & TaskContext::operator= ( TaskContext &&  right)
inlinenoexcept
464 {
465 _task = std::move(right._task);
466 _owner = std::move(right._owner);
467 _consumed = std::move(right._consumed);
468 return *this;
469 }

References _consumed, _owner, and _task.

◆ operator=() [2/2]

TaskContext & TaskContext::operator= ( TaskContext const &  right)
inlinenoexcept
455 {
456 _task = right._task;
457 _owner = right._owner;
458 _consumed = right._consumed;
459 return *this;
460 }

References _consumed, _owner, and _task.

◆ Repeat() [1/3]

TaskContext & TaskContext::Repeat ( )
inline

Repeats the event with the same duration. This will consume the task context, its not possible to repeat the task again from the same task context!

509 {
510 return Repeat(_task->_duration);
511 }
TaskContext & Repeat()
Definition TaskScheduler.h:508

References _task, and Repeat().

Referenced by Repeat(), and Repeat().

◆ Repeat() [2/3]

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

Repeats the event and sets a new duration. std::chrono::seconds(5) for example. This will consume the task context, its not possible to repeat the task again from the same task context!

494 {
496
497 // Set new duration, in-context timing and increment repeat counter
498 _task->_duration = duration;
499 _task->_end += duration;
500 _task->_repeated += 1;
501 (*_consumed) = true;
502 return Dispatch(std::bind(&TaskScheduler::InsertTask, std::placeholders::_1, _task));
503 }
void AssertOnConsumed() const
Asserts if the task was consumed already.
Definition TaskScheduler.cpp:273
TaskScheduler & InsertTask(TaskContainer task)
Insert a new task to the enqueued tasks.
Definition TaskScheduler.cpp:70

References _task, AssertOnConsumed(), Dispatch(), and TaskScheduler::InsertTask().

Referenced by boss_marli::_schedulePhaseSpider(), boss_marli::_schedulePhaseTroll(), boss_thekal::CheckPhaseTransition(), boss_mor_grayhoof::DamageTaken(), boss_isalien::DamageTaken(), boss_ouro::DamageTaken(), boss_leotheras_the_blind::DemonTime(), boss_apothecary_hummel::boss_apothecary_hummelAI::DoAction(), boss_broggok::DoAction(), instance_zulaman::instance_zulaman_InstanceMapScript::DoAction(), boss_alythess::DoAction(), boss_leotheras_the_blind::ElfTime(), boss_ouro::Emerge(), boss_halazzi::EnterPhase(), npc_singularity::FindAndFollowTarget(), boss_glob_of_viscidus::InitializeAI(), npc_rancid_mushroom::InitializeAI(), npc_underbog_mushroom::InitializeAI(), boss_moroes::InitializeGuests(), go_firework_show::InitShow(), boss_grand_warlock_nethekurse::IntroRP(), npc_corrupted_totem::IsSummonedBy(), boss_kormok::IsSummonedBy(), npc_anzu_spirit::IsSummonedBy(), npc_parasitic_shadowfiend::IsSummonedBy(), npc_raging_flames::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_priestess_delrissa::JustEngagedWith(), boss_kormok::JustEngagedWith(), boss_baroness_anastari::boss_baroness_anastariAI::JustEngagedWith(), boss_jarien::JustEngagedWith(), boss_sothos::JustEngagedWith(), boss_kalec::JustEngagedWith(), boss_sathrovarr::JustEngagedWith(), npc_sunblade_scout::JustEngagedWith(), npc_sunblade_arch_mage::JustEngagedWith(), boss_twilight_corrupter::JustEngagedWith(), boss_akilzon::JustEngagedWith(), npc_amanishi_tempest::JustEngagedWith(), npc_amanishi_scout::JustEngagedWith(), npc_healing_ward::JustEngagedWith(), npc_shade_of_jindo::JustEngagedWith(), npc_vilebranch_speaker::JustEngagedWith(), boss_thekal::JustEngagedWith(), npc_zealot_lorkhan::JustEngagedWith(), npc_zealot_zath::JustEngagedWith(), boss_venoxis::JustEngagedWith(), npc_coren_direbrew_sisters::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_captain_skarloc::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_ahnqiraji_critter::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(), 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_wrath_scryer_soccothrates::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(), npc_enraged_spirit::npc_enraged_spiritAI::JustEngagedWith(), boss_curator::JustEngagedWith(), boss_maiden_of_virtue::JustEngagedWith(), boss_midnight::JustEngagedWith(), boss_moroes::JustEngagedWith(), boss_priestess_lackey_commonAI::JustEngagedWith(), boss_kagani_nightstrike::JustEngagedWith(), boss_yazzai::JustEngagedWith(), boss_sacrolash::JustEngagedWith(), boss_alythess::JustEngagedWith(), boss_janalai::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_faerlina::boss_faerlinaAI::JustEngagedWith(), boss_pandemonius::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_grand_warlock_nethekurse::JustEngagedWith(), boss_porung::JustEngagedWith(), boss_warchief_kargath_bladefist::JustEngagedWith(), boss_alar::JustEngagedWith(), boss_high_astromancer_solarian::JustEngagedWith(), boss_void_reaver::JustEngagedWith(), npc_midsummer_ribbon_pole_target::LocateRibbonPole(), boss_nalorakk::MoveInLineOfSight(), npc_ulduar_snow_mound::MoveInLineOfSight(), boss_ayamiss::MovementInform(), boss_lady_vashj::MovementInform(), boss_nazan::MovementInform(), npc_shattered_hand_scout::MovementInform(), boss_kaelthas::MovementInform(), npc_janalai_hatcher::MovementInform(), npc_midsummer_bonfire::npc_midsummer_bonfire(), npc_midsummer_ribbon_pole_target::npc_midsummer_ribbon_pole_target(), boss_high_nethermancer_zerevor::OnAuraRemove(), boss_jeklik::PathEndReached(), boss_kaelthas::PhaseKaelExecute(), boss_malchezaar::Reset(), boss_vexallus::Reset(), npc_apothecary_baxter::Reset(), npc_kiljaeden_controller::Reset(), boss_hexlord_malacrass::Reset(), npc_shade_of_jindo::Reset(), boss_thekal::Reset(), npc_zealot_lorkhan::Reset(), npc_zealot_zath::Reset(), npc_giant_eye_tentacle::Reset(), npc_ahnqiraji_critter::Reset(), boss_kologarn_pit_kill_bunny::Reset(), npc_cosmetic_toy_plane::Reset(), npc_stolen_soul::Reset(), npc_ashtongue_channeler::Reset(), boss_high_king_maulgar::Reset(), boss_omor_the_unscarred::Reset(), boss_watchkeeper_gargolmar::Reset(), boss_magtheridon::Reset(), boss_high_astromancer_solarian::Reset(), npc_injured_patient::npc_injured_patientAI::Reset(), boss_illidan_stormrage::ScheduleAbilities(), boss_razuvious_minion::boss_razuvious_minionAI::ScheduleAttackDummy(), boss_warbringer_omrogg::ScheduleBurningPhase(), boss_hexlord_malacrass::ScheduleClassAbility(), boss_julianne::ScheduleCombat(), boss_romulo::ScheduleCombat(), npc_sunblade_scout::ScheduleCombat(), npc_amanishi_scout::ScheduleCombat(), boss_magtheridon::ScheduleCombatEvents(), npc_amanishi_tempest::ScheduleEvents(), npc_dream_fog::npc_dream_fogAI::ScheduleEvents(), boss_nightbane::ScheduleFly(), boss_nightbane::ScheduleGround(), boss_alar::ScheduleMainSpellAttack(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::ScheduleNextPortal(), boss_warbringer_omrogg::ScheduleNonBurningPhase(), npc_sunblade_scout::ScheduleOOC(), boss_supremus::SchedulePhase(), boss_baroness_anastari::boss_baroness_anastariAI::SchedulePossession(), boss_razuvious::boss_razuviousAI::ScheduleRP(), boss_the_lurker_below::SchedulerPhaseOne(), boss_lady_vashj::ScheduleSpells(), npc_giant_claw_tentacle::ScheduleTasks(), boss_attumen::ScheduleTasks(), boss_ayamiss::ScheduleTasks(), boss_cthun::ScheduleTasks(), instance_hyjal::instance_mount_hyjal_InstanceMapScript::ScheduleWaves(), instance_hyjal::instance_mount_hyjal_InstanceMapScript::SetData(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::SetData(), npc_warchief_portal::SetData(), boss_hydross_the_unstable::SetForm(), boss_nalorakk::ShapeShift(), npc_deathstalker_fearleia::sQuestAccept(), go_firework_show::StartShow(), npc_kiljaeden_controller::SummonedCreatureDies(), boss_netherspite::SwitchToBanishPhase(), and boss_netherspite::SwitchToPortalPhase().

◆ Repeat() [3/3]

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

Repeats the event and set a new duration that is randomized between min and max. std::chrono::seconds(5) for example. This will consume the task context, its not possible to repeat the task again from the same task context!

520 {
522 }

References TaskScheduler::RandomDurationBetween(), and Repeat().

◆ RescheduleAll() [1/2]

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

Reschedule all tasks with the given duration.

625 {
626 return Dispatch(std::bind(&TaskScheduler::RescheduleAll, std::placeholders::_1, duration));
627 }
TaskScheduler & RescheduleAll(std::chrono::duration< _Rep, _Period > const &duration)
Reschedule all tasks with a given duration.
Definition TaskScheduler.h:331

References Dispatch(), and TaskScheduler::RescheduleAll().

Referenced by RescheduleAll().

◆ RescheduleAll() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContext & TaskContext::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.

633 {
635 }
TaskContext & RescheduleAll(std::chrono::duration< _Rep, _Period > const &duration)
Reschedule all tasks with the given duration.
Definition TaskScheduler.h:624

References TaskScheduler::RandomDurationBetween(), and RescheduleAll().

◆ RescheduleGroup() [1/2]

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

Reschedule all tasks of a group with the given duration.

640 {
641 return Dispatch(std::bind(&TaskScheduler::RescheduleGroup<_Rep, _Period>, std::placeholders::_1, group, duration));
642 }

References Dispatch().

Referenced by boss_shirrak_the_dead_watcher::JustEngagedWith(), and RescheduleGroup().

◆ RescheduleGroup() [2/2]

template<class _RepLeft , class _PeriodLeft , class _RepRight , class _PeriodRight >
TaskContext & TaskContext::RescheduleGroup ( TaskScheduler::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.

649 {
651 }
TaskContext & RescheduleGroup(TaskScheduler::group_t const group, std::chrono::duration< _Rep, _Period > const &duration)
Reschedule all tasks of a group with the given duration.
Definition TaskScheduler.h:639

References TaskScheduler::RandomDurationBetween(), and RescheduleGroup().

◆ Schedule() [1/4]

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

Schedule an event with a fixed rate from within the context. Its possible that the new event is executed immediately! Use TaskScheduler::Async to create a task which will be called at the next update tick.

550 {
551 auto const end = _task->_end;
552 return Dispatch([end, time, group, task](TaskScheduler & scheduler) -> TaskScheduler &
553 {
554 return scheduler.ScheduleAt<_Rep, _Period>(end, time, group, task);
555 });
556 }
Definition TaskScheduler.h:45
TaskScheduler & ScheduleAt(timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition TaskScheduler.h:387

References _task, Dispatch(), and TaskScheduler::ScheduleAt().

◆ Schedule() [2/4]

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

Schedule an event with a fixed rate from within the context. Its possible that the new event is executed immediately! Use TaskScheduler::Async to create a task which will be called at the next update tick.

535 {
536 auto const end = _task->_end;
537 return Dispatch([end, time, task](TaskScheduler & scheduler) -> TaskScheduler &
538 {
539 return scheduler.ScheduleAt<_Rep, _Period>(end, time, task);
540 });
541 }

References _task, Dispatch(), and TaskScheduler::ScheduleAt().

Referenced by boss_isalien::DamageTaken(), boss_apothecary_hummel::boss_apothecary_hummelAI::DoAction(), boss_warbringer_omrogg::HandleHeadTalk(), boss_glob_of_viscidus::InitializeAI(), npc_underbog_mushroom::InitializeAI(), Schedule(), Schedule(), boss_warbringer_omrogg::ScheduleBurningPhase(), and boss_warbringer_omrogg::ScheduleNonBurningPhase().

◆ Schedule() [3/4]

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

Schedule an event with a randomized rate between min and max rate from within the context. Its possible that the new event is executed immediately! Use TaskScheduler::Async to create a task which will be called at the next update tick.

577 {
578 return Schedule(TaskScheduler::RandomDurationBetween(min, max), group, task);
579 }
TaskContext & Schedule(std::chrono::duration< _Rep, _Period > const &time, TaskScheduler::task_handler_t const &task)
Definition TaskScheduler.h:533

References TaskScheduler::RandomDurationBetween(), and Schedule().

◆ Schedule() [4/4]

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

Schedule an event with a randomized rate between min and max rate from within the context. Its possible that the new event is executed immediately! Use TaskScheduler::Async to create a task which will be called at the next update tick.

565 {
566 return Schedule(TaskScheduler::RandomDurationBetween(min, max), task);
567 }

References TaskScheduler::RandomDurationBetween(), and Schedule().

◆ SetGroup()

Friends And Related Symbol Documentation

◆ TaskScheduler

friend class TaskScheduler
friend

Member Data Documentation

◆ _consumed

std::shared_ptr<bool> TaskContext::_consumed
private

Marks the task as consumed.

Referenced by operator=(), and operator=().

◆ _owner

std::weak_ptr<TaskScheduler> TaskContext::_owner
private

Owner.

Referenced by operator=(), and operator=().

◆ _task

TaskScheduler::TaskContainer TaskContext::_task
private

Associated task.

Referenced by operator=(), operator=(), Repeat(), Repeat(), Schedule(), and Schedule().


The documentation for this class was generated from the following files: