Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
gts::CStyleTask Class Reference

A Task payload that embeds a function pointer and data argument into the the Task's data. More...

#include <Task.h>

Inherits gts::Task.

Public Types

using TaskRoutine = Task *(*)(void *pData, TaskContext const &taskContext)
 

Public Member Functions

GTS_INLINE CStyleTask ()
 
template<typename TData >
GTS_INLINE CStyleTask (TaskRoutine taskRountine, TData *pData=nullptr)
 
GTS_INLINE CStyleTask (CStyleTask const &)
 
virtual GTS_INLINE Taskexecute (TaskContext const &ctx) final
 
template<typename TData >
GTS_INLINE TData * setData (TData *data)
 
GTS_INLINE void const * getData () const
 
GTS_INLINE void * getData ()
 
template<typename TData >
 CStyleTask (TaskRoutine taskRountine, TData *pData)
 
template<typename TData >
TData * setData (TData *pData)
 
template<typename TData >
void _resetDataDestructor ()
 
- Public Member Functions inherited from gts::Task
GTS_INLINE void addChildTaskWithoutRef (Task *pChild)
 
GTS_INLINE void addChildTaskWithRef (Task *pChild, gts::memory_order order=gts::memory_order::seq_cst)
 
GTS_INLINE void setContinuationTask (Task *pContinuation)
 
GTS_INLINE void recycle ()
 
void waitForAll ()
 
void spawnAndWaitForAll (Task *pChild)
 
GTS_INLINE void setAffinity (uint32_t workerIdx)
 
GTS_INLINE int32_t addRef (int32_t count=1, gts::memory_order order=gts::memory_order::seq_cst)
 
GTS_INLINE int32_t removeRef (int32_t count=1, gts::memory_order order=gts::memory_order::seq_cst)
 
GTS_INLINE void setRef (int32_t count, gts::memory_order order=gts::memory_order::seq_cst)
 
GTS_INLINE void setName (const char *name)
 
GTS_INLINE int32_t refCount (gts::memory_order order=gts::memory_order::acquire) const
 
GTS_INLINE uint32_t getAffinity () const
 
GTS_INLINE bool isStolen () const
 
GTS_INLINE Taskparent ()
 
GTS_INLINE const char * name () const
 

Detailed Description

A Task payload that embeds a function pointer and data argument into the the Task's data.

Constructor & Destructor Documentation

◆ CStyleTask() [1/3]

CStyleTask::CStyleTask ( )

Construct an empty Task. Needed for some container classes.

◆ CStyleTask() [2/3]

template<typename TData >
GTS_INLINE gts::CStyleTask::CStyleTask ( TaskRoutine  taskRountine,
TData *  pData = nullptr 
)
explicit

Construct an Task from a TaskRoutine and data pointer

◆ CStyleTask() [3/3]

CStyleTask::CStyleTask ( CStyleTask const &  )

Copy constructor needed for STL containers. Do not use!

Member Function Documentation

◆ getData() [1/2]

void * CStyleTask::getData ( )
Returns
the user data from the task.

◆ getData() [2/2]

void const * CStyleTask::getData ( ) const
Returns
the const user data from the task.

◆ setData()

template<typename TData >
GTS_INLINE TData* gts::CStyleTask::setData ( TData *  data)

Copies a data pointer into the task.