Leviathan  0.8.0.0
Leviathan game engine
Leviathan::ConditionalTask Class Reference

Encapsulates a function that can later be ran in a free thread. More...

#include <QueuedTask.h>

+ Inheritance diagram for Leviathan::ConditionalTask:

Public Member Functions

DLLEXPORT ConditionalTask (std::function< void()> functorun, std::function< bool()> canberuncheck)
 
virtual DLLEXPORT ~ConditionalTask ()
 
virtual DLLEXPORT bool CanBeRan (const QueuedTaskCheckValues *const checkvalues)
 Calls the checking function to see if the task can be ran. 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

std::function< bool()> TaskCheckingFunc
 The function for checking if the task is allowed to be run. More...
 

Detailed Description

Encapsulates a function that can later be ran in a free thread.

Warning
Function passed to this class should be thread safe

Definition at line 82 of file QueuedTask.h.

Constructor & Destructor Documentation

◆ ConditionalTask()

DLLEXPORT Leviathan::ConditionalTask::ConditionalTask ( std::function< void()>  functorun,
std::function< bool()>  canberuncheck 
)

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

Parameters
canberuncheckIs ran when CanBeRan is called, so it should be relatively cheap to call

Definition at line 45 of file QueuedTask.cpp.

46  :
47  QueuedTask(functorun),
48  TaskCheckingFunc(canberuncheck)
49 {}
DLLEXPORT QueuedTask(std::function< void()> functorun)
Takes in the function which is ran when the Task is ran.
Definition: QueuedTask.cpp:6
std::function< bool()> TaskCheckingFunc
The function for checking if the task is allowed to be run.
Definition: QueuedTask.h:96

◆ ~ConditionalTask()

DLLEXPORT Leviathan::ConditionalTask::~ConditionalTask ( )
virtual

Definition at line 51 of file QueuedTask.cpp.

51 {}

Member Function Documentation

◆ CanBeRan()

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

Calls the checking function to see if the task can be ran.

Reimplemented from Leviathan::QueuedTask.

Definition at line 53 of file QueuedTask.cpp.

55 {
56  return TaskCheckingFunc();
57 }
std::function< bool()> TaskCheckingFunc
The function for checking if the task is allowed to be run.
Definition: QueuedTask.h:96

Member Data Documentation

◆ TaskCheckingFunc

std::function<bool ()> Leviathan::ConditionalTask::TaskCheckingFunc
protected

The function for checking if the task is allowed to be run.

Definition at line 96 of file QueuedTask.h.


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