carb::thread::RelayTaskDesc

Defined in carb/thread/IThreadUtil.h

struct RelayTaskDesc

A descriptor of the relay task to be performed.

This provides the task function itself, the context value and flags to pass to it, and space to store the result for blocking task calls.

For non-blocking tasks, this descriptor will be shallow copied and queued for execution. The caller must guarantee that any pointer parameters passed to the task function will remain valid until the task itself finishes execution. In this case the task function itself is also responsible for cleaning up any resources that are passed to the task function through its context object. As a result of this requirement, none of the values passed to the task should be allocated on the stack.

For blocking calls, the task will be guaranteed to be completed by the time runRelayTask() returns. In this case, the result of the operation (if any) will be available in the task descriptor. Any of the task’s objects may be allocated on the stack if needed since it is guaranteed to block until the task completes. Either the task or the caller may clean up any resources in this case.

Public Members

RelayTaskFn task

The task function to be executed.

The task function itself is responsible for managing any thread safe access to any passed in values.

RelayFlags flags

Flags that control the behavior of this task.

This may be a combination of zero or more of the RelayFlags flags and zero or more task-specific flags.

void *context

An opaque context value to be passed to the task function when it executes.

This will not be accessed or modified in any way before being passed to the task function. The task function itself is responsible for knowing how to properly interpret this value.