OpenBlox
A game engine which provides a simple and easy to learn Lua API.
OB::TaskScheduler Class Reference

#include <TaskScheduler.h>

Public Member Functions

 TaskScheduler (OBEngine *eng)
 
virtual ~TaskScheduler ()
 
bool GetSortsTasks ()
 
void SetSortsTasks (bool sortsTasks)
 
int GetNumSleepingJobs ()
 
int GetNumWaitingJobs ()
 
void tick ()
 
void removeDMBound ()
 
void enqueue (ob_task_fnc fnc, void *metad, ob_uint64 at, bool getsPaused, bool dmBound)
 

Detailed Description

This class is used to schedule tasks to be run on the task thread.

When GetSortsTasks is false, the TaskScheduler will act as a FIFO queue.

Author
John M. Harris, Jr.

Constructor & Destructor Documentation

◆ TaskScheduler()

OB::TaskScheduler::TaskScheduler ( OBEngine eng)

◆ ~TaskScheduler()

virtual OB::TaskScheduler::~TaskScheduler ( )
virtual

Member Function Documentation

◆ enqueue()

void OB::TaskScheduler::enqueue ( ob_task_fnc  fnc,
void *  metad,
ob_uint64  at,
bool  getsPaused,
bool  dmBound 
)

Queues a task to be run at a given time.

Parameters
fncFunction to queue
metadMetadata to be passed to the function.
atWhen this task needs to run.
getsPausedWhether or not this task gets paused with RunService.
dmBoundIf a task is 'DM bound', it is removed from the TaskScheduler when RunService::Stop is called.
Author
John M. Harris, Jr.

◆ GetNumSleepingJobs()

int OB::TaskScheduler::GetNumSleepingJobs ( )

Returns the number of sleeping jobs.

Any job that is currently waiting to run, but will not be run on this tick is considered to be "sleeping".

Returns
int, number of sleeping jobs

◆ GetNumWaitingJobs()

int OB::TaskScheduler::GetNumWaitingJobs ( )

Returns the number of waiting jobs.

Any job that is currently waiting to run, and will be run by the end of this tick is "waiting".

Some jobs can make the TaskScheduler skip remaining waiting jobs, so don't rely on this for anything important.

Returns
int, number of waiting jobs

◆ GetSortsTasks()

bool OB::TaskScheduler::GetSortsTasks ( )

◆ removeDMBound()

void OB::TaskScheduler::removeDMBound ( )

Removes DM bound tasks from the queue.

Author
John M. Harris, Jr.

◆ SetSortsTasks()

void OB::TaskScheduler::SetSortsTasks ( bool  sortsTasks)

◆ tick()

void OB::TaskScheduler::tick ( )

Runs the task scheduler one time, handles any pending tasks and then returns. This operation can add more tasks to the queue.

Author
John M. Harris, Jr.

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