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)
 
TaskContextoperator= (TaskContext const &right)
 
TaskContextoperator= (TaskContext &&right)
 
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.
 
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
418 : _task(), _owner(), _consumed(std::make_shared<bool>(true)) { }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:404
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:407
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:410

◆ TaskContext() [2/4]

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

◆ TaskContext() [3/4]

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

◆ TaskContext() [4/4]

TaskContext::TaskContext ( TaskContext &&  right)
inline
430 : _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.

225{
226 // This was adapted to TC to prevent static analysis tools from complaining.
227 // If you encounter this assertion check if you repeat a TaskContext more then 1 time!
228 ASSERT(!(*_consumed) && "Bad task logic, task context was consumed already!");
229}
#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.

205{
206 return Dispatch(std::bind(&TaskScheduler::Async, std::placeholders::_1, callable));
207}
TaskScheduler & Async(std::function< void()> const &callable)
Definition: TaskScheduler.cpp:27
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:167

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

◆ CancelAll()

TaskContext & TaskContext::CancelAll ( )

Cancels all tasks from within the context.

210{
211 return Dispatch(std::mem_fn(&TaskScheduler::CancelAll));
212}
TaskScheduler & CancelAll()
Definition: TaskScheduler.cpp:33

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.

215{
216 return Dispatch(std::bind(&TaskScheduler::CancelGroup, std::placeholders::_1, group));
217}
TaskScheduler & CancelGroup(group_t const group)
Definition: TaskScheduler.cpp:41

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

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

220{
221 return Dispatch(std::bind(&TaskScheduler::CancelGroupsOf, std::placeholders::_1, std::cref(groups)));
222}
TaskScheduler & CancelGroupsOf(std::vector< group_t > const &groups)
Definition: TaskScheduler.cpp:50

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

◆ ClearGroup()

TaskContext & TaskContext::ClearGroup ( )

Removes the group from the event.

194{
195 _task->_group = std::nullopt;
196 return *this;
197}

◆ 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.

571 {
572 return Dispatch(std::bind(&TaskScheduler::DelayAll<_Rep, _Period>, std::placeholders::_1, duration));
573 }

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.

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

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.

586 {
587 return Dispatch(std::bind(&TaskScheduler::DelayGroup<_Rep, _Period>, std::placeholders::_1, group, duration));
588 }

References Dispatch().

Referenced by DelayGroup().

◆ 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.

595 {
596 return DelayGroup(group, TaskScheduler::RandomDurationBetween(min, max));
597 }
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:585

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

◆ Dispatch()

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

Dispatches an action safe on the TaskScheduler.

168{
169 if (auto const owner = _owner.lock())
170 {
171 apply(*owner);
172 }
173
174 return *this;
175}
void apply(T *val)
Definition: ByteConverter.h:40

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

◆ GetRepeatCounter()

TaskScheduler::repeated_t TaskContext::GetRepeatCounter ( ) const

Returns the repeat counter which increases every time the task is repeated.

200{
201 return _task->_repeated;
202}

Referenced by boss_mor_grayhoof::DamageTaken(), npc_underbog_mushroom::InitializeAI(), npc_spawn_of_marli::JustEngagedWith(), and boss_eye_of_cthun::ScheduleTask().

◆ Invoke()

void TaskContext::Invoke ( )
private

Invokes the associated hook of the task.

232{
233 _task->_task(*this);
234}

Referenced by TaskScheduler::Dispatch().

◆ IsExpired()

bool TaskContext::IsExpired ( ) const

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

178{
179 return _owner.expired();
180}

◆ IsInGroup()

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

Returns true if the event is in the given group.

183{
184 return _task->IsInGroup(group);
185}

◆ operator=() [1/2]

TaskContext & TaskContext::operator= ( TaskContext &&  right)
inline
443 {
444 _task = std::move(right._task);
445 _owner = std::move(right._owner);
446 _consumed = std::move(right._consumed);
447 return *this;
448 }

References _consumed, _owner, and _task.

◆ operator=() [2/2]

TaskContext & TaskContext::operator= ( TaskContext const &  right)
inline
434 {
435 _task = right._task;
436 _owner = right._owner;
437 _consumed = right._consumed;
438 return *this;
439 }

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!

486 {
487 return Repeat(_task->_duration);
488 }
TaskContext & Repeat()
Definition: TaskScheduler.h:485

References _task, and Repeat().

Referenced by 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!

471 {
473
474 // Set new duration, in-context timing and increment repeat counter
475 _task->_duration = duration;
476 _task->_end += duration;
477 _task->_repeated += 1;
478 (*_consumed) = true;
479 return Dispatch(std::bind(&TaskScheduler::InsertTask, std::placeholders::_1, _task));
480 }
TaskScheduler & InsertTask(TaskContainer task)
Insert a new task to the enqueued tasks.
Definition: TaskScheduler.cpp:58
void AssertOnConsumed() const
Asserts if the task was consumed already.
Definition: TaskScheduler.cpp:224

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

Referenced by boss_thekal::boss_thekalAI::CheckPhaseTransition(), boss_mor_grayhoof::DamageTaken(), boss_isalien::DamageTaken(), boss_malchezaar::DamageTaken(), boss_ouro::DamageTaken(), boss_apothecary_hummel::boss_apothecary_hummelAI::DoAction(), boss_broggok::DoAction(), boss_ouro::Emerge(), boss_glob_of_viscidus::InitializeAI(), npc_underbog_mushroom::InitializeAI(), npc_corrupted_totem::IsSummonedBy(), boss_kormok::IsSummonedBy(), boss_attumen::boss_attumenAI::IsSummonedBy(), boss_mor_grayhoof::JustEngagedWith(), boss_malchezaar::JustEngagedWith(), npc_malchezaar_axe::JustEngagedWith(), boss_kormok::JustEngagedWith(), boss_baroness_anastari::boss_baroness_anastariAI::JustEngagedWith(), boss_jarien::JustEngagedWith(), boss_sothos::JustEngagedWith(), boss_twilight_corrupter::JustEngagedWith(), npc_batrider::JustEngagedWith(), npc_healing_ward::JustEngagedWith(), npc_shade_of_jindo::JustEngagedWith(), npc_vilebranch_speaker::JustEngagedWith(), boss_thekal::boss_thekalAI::JustEngagedWith(), npc_zealot_lorkhan::npc_zealot_lorkhanAI::JustEngagedWith(), npc_zealot_zath::npc_zealot_zathAI::JustEngagedWith(), npc_coren_direbrew_sisters::JustEngagedWith(), npc_hallows_end_soh::JustEngagedWith(), boss_azuregos::boss_azuregosAI::JustEngagedWith(), boss_aeonus::JustEngagedWith(), boss_chrono_lord_deja::JustEngagedWith(), boss_temporus::JustEngagedWith(), boss_isalien::JustEngagedWith(), npc_anubisath_guardian::JustEngagedWith(), npc_obsidian_destroyer::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(), boss_talon_king_ikiss::JustEngagedWith(), boss_dalliah_the_doomsayer::JustEngagedWith(), boss_zereketh_the_unbound::JustEngagedWith(), boss_commander_sarannis::JustEngagedWith(), boss_high_botanist_freywinn::JustEngagedWith(), boss_laj::JustEngagedWith(), boss_thorngrin_the_tender::JustEngagedWith(), boss_warp_splinter::JustEngagedWith(), npc_raliq_the_drunk::npc_raliq_the_drunkAI::JustEngagedWith(), npc_steamrigger_mechanic::JustEngagedWith(), boss_midnight::boss_midnightAI::JustEngagedWith(), npc_ohgan::npc_ohganAI::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_hungarfen::JustEngagedWith(), boss_ayamiss::MovementInform(), npc_apothecary_baxter::Reset(), npc_shade_of_jindo::Reset(), npc_eye_tentacle::Reset(), npc_giant_eye_tentacle::Reset(), npc_ahnqiraji_critter::Reset(), npc_raliq_the_drunk::npc_raliq_the_drunkAI::Reset(), npc_dream_fog::npc_dream_fogAI::ScheduleEvents(), boss_baroness_anastari::boss_baroness_anastariAI::SchedulePossession(), boss_commander_sarannis::ScheduleReinforcements(), boss_eye_of_cthun::ScheduleTask(), npc_giant_claw_tentacle::ScheduleTasks(), boss_attumen::boss_attumenAI::ScheduleTasks(), boss_ayamiss::ScheduleTasks(), boss_cthun::ScheduleTasks(), and instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::SetData().

◆ 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!

497 {
499 }

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.

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

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.

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

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.

617 {
618 return Dispatch(std::bind(&TaskScheduler::RescheduleGroup<_Rep, _Period>, std::placeholders::_1, group, duration));
619 }

References Dispatch().

Referenced by 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.

626 {
628 }
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:616

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.

527 {
528 auto const end = _task->_end;
529 return Dispatch([end, time, group, task](TaskScheduler & scheduler) -> TaskScheduler &
530 {
531 return scheduler.ScheduleAt<_Rep, _Period>(end, time, group, task);
532 });
533 }
Definition: TaskScheduler.h:36
TaskScheduler & ScheduleAt(timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition: TaskScheduler.h:366

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.

512 {
513 auto const end = _task->_end;
514 return Dispatch([end, time, task](TaskScheduler & scheduler) -> TaskScheduler &
515 {
516 return scheduler.ScheduleAt<_Rep, _Period>(end, time, task);
517 });
518 }

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

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

◆ 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.

554 {
555 return Schedule(TaskScheduler::RandomDurationBetween(min, max), group, task);
556 }
TaskContext & Schedule(std::chrono::duration< _Rep, _Period > const &time, TaskScheduler::task_handler_t const &task)
Definition: TaskScheduler.h:510

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.

542 {
543 return Schedule(TaskScheduler::RandomDurationBetween(min, max), task);
544 }

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

◆ SetGroup()

Friends And Related Function 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=().

◆ _owner

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

Owner.

Referenced by operator=().

◆ _task

TaskScheduler::TaskContainer TaskContext::_task
private

Associated task.

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