Leviathan  0.8.0.0
Leviathan game engine
Leviathan::DelayedTask Class Reference

Encapsulates a function that is ran after a time period. More...

#include <QueuedTask.h>

+ Inheritance diagram for Leviathan::DelayedTask:

Public Member Functions

DLLEXPORT DelayedTask (std::function< void()> functorun, const MicrosecondDuration &delaytime)
 
DLLEXPORT DelayedTask (std::function< void()> functorun, const WantedClockType::time_point &executetime)
 
virtual DLLEXPORT ~DelayedTask ()
 
virtual DLLEXPORT bool CanBeRan (const QueuedTaskCheckValues *const checkvalues)
 Checks if the current time is past the time stamp. More...
 
- Public Member Functions inherited from Leviathan::QueuedTask
DLLEXPORT QueuedTask (std::function< void()> functorun)
 Takes in the function which is ran when the Task is ran. More...
 
virtual DLLEXPORT ~QueuedTask ()
 
virtual DLLEXPORT void RunTask ()
 Runs the stored function. More...
 
virtual DLLEXPORT bool MustBeRanBefore (int eventtypeidentifier)
 Function called by ThreadingManager before certain events to make proper tasks finish before certain operations. More...
 
virtual DLLEXPORT bool IsRepeating ()
 Function called by ThreadingManager AFTER running the task //. More...
 

Protected Attributes

WantedClockType::time_point ExecutionTime
 The time after which this task may be ran. More...
 

Detailed Description

Encapsulates a function that is ran after a time period.

Warning
Function passed to this class should be thread safe

Definition at line 130 of file QueuedTask.h.

Constructor & Destructor Documentation

◆ DelayedTask() [1/2]

DLLEXPORT Leviathan::DelayedTask::DelayedTask ( std::function< void()>  functorun,
const MicrosecondDuration delaytime 
)

Constructs a task that can be controlled when it can be ran

Parameters
delaytimeIs used to control when the task can run
See also
QueuedTask

Definition at line 95 of file QueuedTask.cpp.

96  : QueuedTask(functorun),
98 {
99 
100 }
static DLLEXPORT WantedClockType::time_point GetThreadSafeSteadyTimePoint()
DLLEXPORT QueuedTask(std::function< void()> functorun)
Takes in the function which is ran when the Task is ran.
Definition: QueuedTask.cpp:6
WantedClockType::time_point ExecutionTime
The time after which this task may be ran.
Definition: QueuedTask.h:151

◆ DelayedTask() [2/2]

DLLEXPORT Leviathan::DelayedTask::DelayedTask ( std::function< void()>  functorun,
const WantedClockType::time_point &  executetime 
)

Constructs a task that can be controlled when it can be ran

Parameters
executetimeIs used to control when the task can run
See also
QueuedTask

Definition at line 102 of file QueuedTask.cpp.

103  :
104  QueuedTask(functorun), ExecutionTime(executetime)
105 {
106 
107 }
DLLEXPORT QueuedTask(std::function< void()> functorun)
Takes in the function which is ran when the Task is ran.
Definition: QueuedTask.cpp:6
WantedClockType::time_point ExecutionTime
The time after which this task may be ran.
Definition: QueuedTask.h:151

◆ ~DelayedTask()

DLLEXPORT Leviathan::DelayedTask::~DelayedTask ( )
virtual

Definition at line 109 of file QueuedTask.cpp.

109  {
110 
111 }

Member Function Documentation

◆ CanBeRan()

DLLEXPORT bool Leviathan::DelayedTask::CanBeRan ( const QueuedTaskCheckValues *const  checkvalues)
virtual

Checks if the current time is past the time stamp.

Controlled by the value of ExecutionTime

Reimplemented from Leviathan::QueuedTask.

Definition at line 113 of file QueuedTask.cpp.

115 {
116  // Check is the current time past our timestamp //
117  return checkvalues->CurrentTime >= ExecutionTime;
118 }
WantedClockType::time_point CurrentTime
Time the task set iteration started (may be slightly off, but it doesn't matter) //.
Definition: QueuedTask.h:27
WantedClockType::time_point ExecutionTime
The time after which this task may be ran.
Definition: QueuedTask.h:151

Member Data Documentation

◆ ExecutionTime

WantedClockType::time_point Leviathan::DelayedTask::ExecutionTime
protected

The time after which this task may be ran.

Definition at line 151 of file QueuedTask.h.


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