CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Task Queue Lifecycle

Macros

#define tqStart   taskqueueStart
 
#define tqTick   taskqueueTick
 
#define tqShutdown(tq, wait)   taskqueueStop(tq, wait)
 
#define tqRelease(ptq)   objRelease(ptq)
 

Functions

TaskQueue * tqCreate (strref name, TaskQueueConfig *tqconfig)
 

Detailed Description

Macro Definition Documentation

◆ tqRelease

#define tqRelease (   ptq)    objRelease(ptq)

void tqRelease(TaskQueue **ptq)

Release a reference to a task queue. Decrements refcount and destroys queue when it reaches zero.

Parameters
ptqPointer to task queue pointer (set to NULL after release)

Definition at line 111 of file taskqueue.h.

◆ tqShutdown

#define tqShutdown (   tq,
  wait 
)    taskqueueStop(tq, wait)

bool tqShutdown(TaskQueue *tq, int64 wait)

Attempt to shut down a queue. If wait is nonzero, will wait up to that duration for workers to exit.

Parameters
tqTask queue to shut down
waitMaximum time to wait for shutdown, or 0 for non-blocking
Returns
true if the queue is completely shut down and all worker threads are finished

Definition at line 104 of file taskqueue.h.

◆ tqStart

#define tqStart   taskqueueStart

bool tqStart(TaskQueue *tq)

Start or re-start a queue to begin processing tasks. Spawns worker threads and begins task execution.

Parameters
tqTask queue to start
Returns
true if queue was started successfully

Definition at line 87 of file taskqueue.h.

◆ tqTick

#define tqTick   taskqueueTick

int64 tqTick(TaskQueue *tq)

Tick a manual queue to process one or more tasks. Only valid for queues created with TQ_Manual flag.

Parameters
tqManual task queue to tick
Returns
Time until next scheduled task, or -1 if no tasks pending

Definition at line 95 of file taskqueue.h.

Function Documentation

◆ tqCreate()

TaskQueue * tqCreate ( strref  name,
TaskQueueConfig tqconfig 
)

TaskQueue *tqCreate(strref name, TaskQueueConfig *tqconfig)

Create a task queue but does not start it. Call tqStart() after creation to begin processing tasks.

Parameters
nameName for the queue (used in logging and monitoring)
tqconfigConfiguration created with one of the tqPreset functions
Returns
New task queue instance, or NULL on failure