Nugget
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
psyqo::TaskQueue Class Reference

A task queue for processing tasks sequentially. More...

#include <psyqo/task.hh>

Classes

class  Task
 The Task class. More...
 

Public Member Functions

void reset ()
 Resets the queue.
 
TaskQueuestartWith (Task &&)
 Enqueues a task for execution.
 
TaskQueuestartWith (eastl::function< void(Task *)> &&fun)
 
TaskQueuethen (Task &&)
 Enqueues a task for execution.
 
TaskQueuethen (eastl::function< void(Task *)> &&fun)
 
TaskQueuebutCatch (eastl::function< void(TaskQueue *)> &&)
 Sets the exception handler.
 
TaskQueuefinally (eastl::function< void(TaskQueue *)> &&)
 Sets the finally handler.
 
void run ()
 Runs the task queue.
 
Task schedule ()
 Schedules the task queue to another task queue.
 
bool isRunning () const
 Queries the status of the queue.
 

Static Public Member Functions

static Task DelayedTask (uint32_t delay, GPU &)
 Creates a delayed task.
 

Friends

class Task
 

Detailed Description

A task queue for processing tasks sequentially.

This class is used to process a sequence of tasks one after the other. The design is loosely inspired by the JavaScript Promise API. A task is effectively a lambda function. A queue can be run multiple times, and can also be embedded within another queue.

Member Function Documentation

◆ butCatch()

psyqo::TaskQueue & psyqo::TaskQueue::butCatch ( eastl::function< void(TaskQueue *)> &&  fun)

Sets the exception handler.

This method will set the exception handler. The exception handler will be called if any of the tasks in the queue throws an exception. The exception handler will be called with the task queue as its argument. Calling this while the queue is running is undefined behavior.

◆ DelayedTask()

psyqo::TaskQueue::Task psyqo::TaskQueue::DelayedTask ( uint32_t  delay,
GPU gpu 
)
static

Creates a delayed task.

This method is a convenience method to create a task that will be executed after a delay. The delay is specified in microseconds.

Parameters
delayThe delay in microseconds.

◆ finally()

psyqo::TaskQueue & psyqo::TaskQueue::finally ( eastl::function< void(TaskQueue *)> &&  fun)

Sets the finally handler.

This method will set the finally handler. The finally handler will be called after all tasks in the queue have been executed, or after the exception handler. The finally handler will be called with the task queue as its argument. Calling this while the queue is running is undefined behavior.

◆ isRunning()

bool psyqo::TaskQueue::isRunning ( ) const
inline

Queries the status of the queue.

Returns
true if the queue is running, false otherwise.

◆ reset()

void psyqo::TaskQueue::reset ( )

Resets the queue.

This method resets the queue to its initial state. Calling this method while the queue is running is undefined behavior.

◆ run()

void psyqo::TaskQueue::run ( )

Runs the task queue.

This method will start running the queue. The queue will continue to run until all tasks have been executed, or until an exception is thrown. This method can be called multiple times, in order to execute the whole queue multiple times. Calling this while the queue is already running is undefined behavior.

◆ schedule()

psyqo::TaskQueue::Task psyqo::TaskQueue::schedule ( )

Schedules the task queue to another task queue.

This method will enable embedding the queue into another one. Exceptions will be cascading.

◆ startWith() [1/2]

TaskQueue & psyqo::TaskQueue::startWith ( eastl::function< void(Task *)> &&  fun)
inline

◆ startWith() [2/2]

psyqo::TaskQueue & psyqo::TaskQueue::startWith ( Task &&  task)

Enqueues a task for execution.

This method will enqueue a task for execution, while resetting the queue first. This means that any previously enqueued tasks will be removed first. Any exception handler or finally handler will also be cleared out. Calling this while the queue is running is undefined behavior.

◆ then() [1/2]

TaskQueue & psyqo::TaskQueue::then ( eastl::function< void(Task *)> &&  fun)
inline

◆ then() [2/2]

psyqo::TaskQueue & psyqo::TaskQueue::then ( Task &&  task)

Enqueues a task for execution.

This method will enqueue a task for execution. The task will be executed after all previously enqueued tasks have been executed. Calling this while the queue is running is undefined behavior.

Friends And Related Symbol Documentation

◆ Task

friend class Task
friend

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