TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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. More...
 
bool IsInGroup (TaskScheduler::group_t const group) const
 Returns true if the event is in the given group. More...
 
TaskContextSetGroup (TaskScheduler::group_t const group)
 Sets the event in the given group. More...
 
TaskContextClearGroup ()
 Removes the group from the event. More...
 
TaskScheduler::repeated_t GetRepeatCounter () const
 Returns the repeat counter which increases every time the task is repeated. More...
 
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. More...
 
TaskContextCancelGroup (TaskScheduler::group_t const group)
 Cancel all tasks of a single group from within the context. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class _Rep , class _Period >
TaskContextRescheduleAll (std::chrono::duration< _Rep, _Period > const &duration)
 Reschedule all tasks with the given duration. More...
 
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. More...
 
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. More...
 
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. More...
 

Private Member Functions

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

Private Attributes

TaskScheduler::TaskContainer _task
 Associated task. More...
 
std::weak_ptr< TaskScheduler_owner
 Owner. More...
 
std::shared_ptr< bool_consumed
 Marks the task as consumed. More...
 

Friends

class TaskScheduler
 

Constructor & Destructor Documentation

TaskContext::TaskContext ( )
inline
430  : _task(), _owner(), _consumed(std::make_shared<bool>(true)) { }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:422
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419
TaskContext::TaskContext ( TaskScheduler::TaskContainer &&  task,
std::weak_ptr< TaskScheduler > &&  owner 
)
inlineexplicit
434  : _task(task), _owner(owner), _consumed(std::make_shared<bool>(false)) { }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:422
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419
TaskContext::TaskContext ( TaskContext const right)
inline
438  : _task(right._task), _owner(right._owner), _consumed(right._consumed) { }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:422
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419
TaskContext::TaskContext ( TaskContext &&  right)
inline
442  : _task(std::move(right._task)), _owner(std::move(right._owner)), _consumed(std::move(right._consumed)) { }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:422
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419

Member Function Documentation

void TaskContext::AssertOnConsumed ( ) const
private

Asserts if the task was consumed already.

220 {
221  // This was adapted to TC to prevent static analysis tools from complaining.
222  // If you encounter this assertion check if you repeat a TaskContext more then 1 time!
223  ASSERT(!(*_consumed) && "Bad task logic, task context was consumed already!");
224 }
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:422
#define ASSERT
Definition: Errors.h:55
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.

200 {
201  return Dispatch(std::bind(&TaskScheduler::Async, std::placeholders::_1, callable));
202 }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164
TaskScheduler & Async(std::function< void()> const &callable)
Definition: TaskScheduler.cpp:38

+ Here is the call graph for this function:

TaskContext & TaskContext::CancelAll ( )

Cancels all tasks from within the context.

205 {
206  return Dispatch(std::mem_fn(&TaskScheduler::CancelAll));
207 }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164
TaskScheduler & CancelAll()
Definition: TaskScheduler.cpp:44

+ Here is the call graph for this function:

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

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

210 {
211  return Dispatch(std::bind(&TaskScheduler::CancelGroup, std::placeholders::_1, group));
212 }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164
TaskScheduler & CancelGroup(group_t const group)
Definition: TaskScheduler.cpp:52

+ Here is the call graph for this function:

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

215 {
216  return Dispatch(std::bind(&TaskScheduler::CancelGroupsOf, std::placeholders::_1, std::cref(groups)));
217 }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164
TaskScheduler & CancelGroupsOf(std::vector< group_t > const &groups)
Definition: TaskScheduler.cpp:61

+ Here is the call graph for this function:

TaskContext & TaskContext::ClearGroup ( )

Removes the group from the event.

189 {
190  _task->_group = boost::none;
191  return *this;
192 }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
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.

583  {
584  return Dispatch(std::bind(&TaskScheduler::DelayAll<_Rep, _Period>, std::placeholders::_1, duration));
585  }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164

+ Here is the call graph for this function:

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.

591  {
593  }
TaskContext & DelayAll(std::chrono::duration< _Rep, _Period > const &duration)
Delays all tasks with the given duration from within the context.
Definition: TaskScheduler.h:582
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:397

+ Here is the call graph for this function:

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.

598  {
599  return Dispatch(std::bind(&TaskScheduler::DelayGroup<_Rep, _Period>, std::placeholders::_1, group, duration));
600  }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164

+ Here is the call graph for this function:

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.

607  {
609  }
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:597
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:397

+ Here is the call graph for this function:

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

Dispatches an action safe on the TaskScheduler.

165 {
166  if (auto const owner = _owner.lock())
167  apply(*owner);
168 
169  return *this;
170 }
void apply(T *val)
Definition: ByteConverter.h:41
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419

+ Here is the call graph for this function:

TaskScheduler::repeated_t TaskContext::GetRepeatCounter ( ) const

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

195 {
196  return _task->_repeated;
197 }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416

+ Here is the caller graph for this function:

void TaskContext::Invoke ( )
private

Invokes the associated hook of the task.

227 {
228  _task->_task(*this);
229 }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416

+ Here is the caller graph for this function:

bool TaskContext::IsExpired ( ) const

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

173 {
174  return _owner.expired();
175 }
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419
bool TaskContext::IsInGroup ( TaskScheduler::group_t const  group) const

Returns true if the event is in the given group.

178 {
179  return _task->IsInGroup(group);
180 }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
TaskContext& TaskContext::operator= ( TaskContext const right)
inline
446  {
447  _task = right._task;
448  _owner = right._owner;
449  _consumed = right._consumed;
450  return *this;
451  }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:422
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419
TaskContext& TaskContext::operator= ( TaskContext &&  right)
inline
455  {
456  _task = std::move(right._task);
457  _owner = std::move(right._owner);
458  _consumed = std::move(right._consumed);
459  return *this;
460  }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
std::shared_ptr< bool > _consumed
Marks the task as consumed.
Definition: TaskScheduler.h:422
std::weak_ptr< TaskScheduler > _owner
Owner.
Definition: TaskScheduler.h:419
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!

483  {
485 
486  // Set new duration, in-context timing and increment repeat counter
487  _task->_duration = duration;
488  _task->_end += duration;
489  _task->_repeated += 1;
490  (*_consumed) = true;
491  return Dispatch(std::bind(&TaskScheduler::InsertTask, std::placeholders::_1, _task));
492  }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164
TaskScheduler & InsertTask(TaskContainer task)
Insert a new task to the enqueued tasks.
Definition: TaskScheduler.cpp:69
void AssertOnConsumed() const
Asserts if the task was consumed already.
Definition: TaskScheduler.cpp:219

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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!

498  {
499  return Repeat(_task->_duration);
500  }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
TaskContext & Repeat()
Definition: TaskScheduler.h:497
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!

509  {
511  }
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:397
TaskContext & Repeat()
Definition: TaskScheduler.h:497

+ Here is the call graph for this function:

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

Reschedule all tasks with the given duration.

614  {
615  return Dispatch(std::bind(&TaskScheduler::RescheduleAll, std::placeholders::_1, duration));
616  }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164
TaskScheduler & RescheduleAll(std::chrono::duration< _Rep, _Period > const &duration)
Reschedule all tasks with a given duration.
Definition: TaskScheduler.h:326

+ Here is the call graph for this function:

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.

622  {
624  }
T max(const T &x, const T &y)
Definition: g3dmath.h:320
TaskContext & RescheduleAll(std::chrono::duration< _Rep, _Period > const &duration)
Reschedule all tasks with the given duration.
Definition: TaskScheduler.h:613
T min(const T &x, const T &y)
Definition: g3dmath.h:305
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:397

+ Here is the call graph for this function:

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.

629  {
630  return Dispatch(std::bind(&TaskScheduler::RescheduleGroup<_Rep, _Period>, std::placeholders::_1, group, duration));
631  }
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164

+ Here is the call graph for this function:

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.

638  {
640  }
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:628
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:397

+ Here is the call graph for this function:

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.

524  {
525  auto const end = _task->_end;
526  return Dispatch([end, time, task](TaskScheduler& scheduler) -> TaskScheduler&
527  {
528  return scheduler.ScheduleAt<_Rep, _Period>(end, time, task);
529  });
530  }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
Definition: TaskScheduler.h:49
TaskScheduler & ScheduleAt(timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition: TaskScheduler.h:377
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

539  {
540  auto const end = _task->_end;
541  return Dispatch([end, time, group, task](TaskScheduler& scheduler) -> TaskScheduler&
542  {
543  return scheduler.ScheduleAt<_Rep, _Period>(end, time, group, task);
544  });
545  }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416
Definition: TaskScheduler.h:49
TaskScheduler & ScheduleAt(timepoint_t const &end, std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition: TaskScheduler.h:377
TaskContext & Dispatch(std::function< TaskScheduler &(TaskScheduler &)> const &apply)
Dispatches an action safe on the TaskScheduler.
Definition: TaskScheduler.cpp:164

+ Here is the call graph for this function:

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.

554  {
556  }
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:397
TaskContext & Schedule(std::chrono::duration< _Rep, _Period > const &time, TaskScheduler::task_handler_t const &task)
Definition: TaskScheduler.h:522

+ Here is the call graph for this function:

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.

566  {
567  return Schedule(TaskScheduler::RandomDurationBetween(min, max), group, task);
568  }
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
static std::chrono::milliseconds RandomDurationBetween(std::chrono::duration< _RepLeft, _PeriodLeft > const &min, std::chrono::duration< _RepRight, _PeriodRight > const &max)
Definition: TaskScheduler.h:397
TaskContext & Schedule(std::chrono::duration< _Rep, _Period > const &time, TaskScheduler::task_handler_t const &task)
Definition: TaskScheduler.h:522

+ Here is the call graph for this function:

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

Sets the event in the given group.

183 {
184  _task->_group = group;
185  return *this;
186 }
TaskScheduler::TaskContainer _task
Associated task.
Definition: TaskScheduler.h:416

Friends And Related Function Documentation

friend class TaskScheduler
friend

Member Data Documentation

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

Marks the task as consumed.

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

Owner.

TaskScheduler::TaskContainer TaskContext::_task
private

Associated task.


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