VSTGUI 4.10
Graphical User Interface Framework not only for VST plugins
Loading...
Searching...
No Matches
VSTGUI::Tasks Namespace Reference

Simple Task Concurrency API. More...

Functions

const Queue & mainQueue ()
 Get the main/UI serial queue.
 
const Queue & backgroundQueue ()
 Get the background concurrent queue.
 
Queue makeSerialQueue (const char *name)
 Make a new serial queue.
 
void releaseSerialQueue (const Queue &queue)
 Release a serial queue.
 
void schedule (const Queue &queue, Task &&task)
 Schedule a task to be executed asynchronously on a queue.
 
void waitAllTasksExecuted (const Queue &queue)
 Wait for all tasks in the queue to complete execution.
 

Detailed Description

Simple Task Concurrency API.

The Task Concurrency API facilitates scheduling tasks for execution on background threads, either concurrently or sequentially. This API also enables the scheduling of tasks on the main thread from any other thread.

This API can be used while the VSTGUI library is initialized. Upon deinitialization, triggered by the mandatory exit() call, this API ensures that all scheduled tasks are completed prior to returning.

Please note that once a task has been dispatched, it cannot be canceled.

Function Documentation

◆ backgroundQueue()

const Queue & backgroundQueue ( )

Get the background concurrent queue.

Tasks scheduled on this queue are performed concurrently on background threads. The number of background threads depends on the system's CPU core count.

Can be called from any thread.

Returns
the shared background queue

◆ mainQueue()

const Queue & mainQueue ( )

Get the main/UI serial queue.

Tasks scheduled on this queue are performed sequentially on the main/ui thread.

Can be called from any thread.

Returns
the shared main queue

◆ makeSerialQueue()

Queue makeSerialQueue ( const char * name)

Make a new serial queue.

Tasks scheduled on this queue are executed sequentially on a background thread.

The caller owns the queue, and needs to release the queue via the releaseSerialQueue() function.

Can be called from any thread.

Parameters
namethe name of the serial queue (optional)
Returns
a new serial queue

◆ releaseSerialQueue()

void releaseSerialQueue ( const Queue & queue)

Release a serial queue.

This function will block until all tasks of the queue were executed.

Can be called from any thread.

Parameters
queuethe queue which to release

◆ schedule()

void schedule ( const Queue & queue,
Task && task )

Schedule a task to be executed asynchronously on a queue.

Can be called from any thread, but should not be called from realtime constraint threads as it may involves locks and memory allocations

Parameters
queueon which queue to perform the task
tasktask to be performed

◆ waitAllTasksExecuted()

void waitAllTasksExecuted ( const Queue & queue)

Wait for all tasks in the queue to complete execution.

Can only be called from the main thread.

Parameters
queueon which queue to perform the task