GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::execution::Task Class Reference

Statically scheduled unit of work to be executed by an Executor as part of a task graph. More...

#include <GREM/execution/Task.hpp>

Public Types

using ParallelIndex = uint16_t
 Index of a parallel sub-task.
using ParallelCount = ParallelIndex
 Number of a parallel sub-tasks.
using Function = void (*)(void* context, byte* taskSharedMemory, ParallelIndex parallelIndex, ParallelCount parallelism)
 Callback function pointer that executes a task.
using GraphIndex = ParallelIndex
 Index of a task in a task graph.
using Count = ParallelCount
 Number of tasks in a task graph.
using SharedMemoryOffset = uint32_t
 Byte offset into the shared memory allocated for a task.
using SharedMemorySize = uint32_t
 Size, in bytes, of shared memory allocated for a task.
using DependencyIndices = SmallArrayList<GraphIndex, 12>
 List of indices of previous tasks that a task depends on.

Public Member Functions

 Task (Function function, SharedMemoryOffset sharedMemoryOffset, ParallelIndex parallelIndex, ParallelCount parallelism, DependencyIndices dependencyIndices, UniquePointer< char[]> name) noexcept
 Construct a task.
void execute (void *context, byte *sharedMemory) const
 Execute the task.
SharedMemoryOffset getSharedMemoryOffset () const noexcept
 Get the expected offset of this task's reserved memory range in the total shared task memory allocated for the task graph.
Span< const GraphIndex > getDependencyIndices () const noexcept
 Get the task indices of this task's dependencies in the task graph.
CStringView getName () const noexcept
 Get the human-readable name of the task.

Static Public Attributes

static constexpr size_t MAX_GRAPH_SIZE = size_t{Limits<Count>::MAX}
 The maximum supported number of tasks in a task graph.

Detailed Description

Statically scheduled unit of work to be executed by an Executor as part of a task graph.

See also
Scheduler

Member Typedef Documentation

◆ ParallelIndex

Index of a parallel sub-task.

◆ ParallelCount

Number of a parallel sub-tasks.

◆ Function

using grem::execution::Task::Function = void (*)(void* context, byte* taskSharedMemory, ParallelIndex parallelIndex, ParallelCount parallelism)

Callback function pointer that executes a task.

◆ GraphIndex

Index of a task in a task graph.

◆ Count

Number of tasks in a task graph.

◆ SharedMemoryOffset

Byte offset into the shared memory allocated for a task.

◆ SharedMemorySize

Size, in bytes, of shared memory allocated for a task.

◆ DependencyIndices

List of indices of previous tasks that a task depends on.

Constructor & Destructor Documentation

◆ Task()

grem::execution::Task::Task ( Function function,
SharedMemoryOffset sharedMemoryOffset,
ParallelIndex parallelIndex,
ParallelCount parallelism,
DependencyIndices dependencyIndices,
UniquePointer< char[]> name )
inlinenoexcept

Construct a task.

Parameters
functioncallback function that executes the task.
sharedMemoryOffsetoffset of the first byte allocated for this task in the shared task memory.
parallelIndexsub-task index of the task. Must be less than parallelism.
parallelismnumber of parallel sub-tasks that this task is part of. Must be positive.
dependencyIndiceslist of indices of previous tasks that this task depends on.
nameowning pointer to a null-terminated UTF-8-encoded string containing the human-readable name of the task, or nullptr to create an unnamed task.

Member Function Documentation

◆ execute()

void grem::execution::Task::execute ( void * context,
byte * sharedMemory ) const
inline

Execute the task.

Parameters
contextuser-defined context pointer to pass to the callback function's void* context parameter.
sharedMemorynon-owning pointer to the start of the memory allocated for all tasks in the task graph. The callback function will be passed this pointer plus the value of the task's getSharedMemoryOffset().
Exceptions
anyexception thrown by the task's callback function.

◆ getSharedMemoryOffset()

SharedMemoryOffset grem::execution::Task::getSharedMemoryOffset ( ) const
inlinenodiscardnoexcept

Get the expected offset of this task's reserved memory range in the total shared task memory allocated for the task graph.

Returns
the shared memory offset of the task.

◆ getDependencyIndices()

Span< const GraphIndex > grem::execution::Task::getDependencyIndices ( ) const
inlinenodiscardnoexcept

Get the task indices of this task's dependencies in the task graph.

Returns
the list of indices of previous tasks that this task depends on.

◆ getName()

CStringView grem::execution::Task::getName ( ) const
inlinenodiscardnoexcept

Get the human-readable name of the task.

Returns
a UTF-8-encoded string containing the task name, or an empty string if the task is unnamed.

Member Data Documentation

◆ MAX_GRAPH_SIZE

size_t grem::execution::Task::MAX_GRAPH_SIZE = size_t{Limits<Count>::MAX}
staticconstexpr

The maximum supported number of tasks in a task graph.


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