Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
OsThreadWrapper

Macros

#define GTS_CONTEXT_SWITCH_CYCLES   #error "Replace with custom definition"
 
#define GTS_THREAD_AFFINITY_ALL   #error "Replace with custom definition"
 
#define GTS_THREAD_PRIORITY_HIGHEST   #error "Replace with custom definition"
 
#define GTS_THREAD_PRIORITY_ABOVE_NORMAL   #error "Replace with custom definition"
 
#define GTS_THREAD_PRIORITY_NORMAL   #error "Replace with custom definition"
 
#define GTS_THREAD_PRIORITY_BELOW_NORMAL   #error "Replace with custom definition"
 
#define GTS_THREAD_PRIORITY_BELOW_LOWEST   #error "Replace with custom definition"
 
#define GTS_THREAD_HANDLE_TYPE   #error "Replace with custom definition"
 
#define GTS_THREAD_ID_TYPE   #error "Replace with custom definition"
 
#define GTS_THREAD_FUNCTION_DECL(name)   #error "Replace with custom definition"
 
#define GTS_THREAD_FUNCTION_DEFN(cls, name)   #error "Replace with custom definition"
 
#define GTS_THREAD_AFFINITY_SET_TYPE   #error "Replace with custom definition"
 A description of an CPU affinity set for a threa. More...
 
#define GTS_CREATE_THREAD(threadHandle, tid, func, arg, stackSize)   #error "Replace with custom definition"
 Creates and launches a new thread of execution. More...
 
#define GTS_JOIN_THREAD(threadHandle)   #error "Replace with custom definition"
 Blocks until the thread exits. More...
 
#define GTS_DESTROY_THREAD(threadHandle)   #error "Replace with custom definition"
 Frees a ThreadHandle. More...
 
#define GTS_SET_THREAD_GROUP_AFFINITY(threadHandle, groupId, affinitySet)   #error "Replace with custom definition"
 
#define GTS_SET_THREAD_PRIORITY(tid, priority)   #error "Replace with custom definition"
 Sets the priority for the thread. More...
 
#define GTS_SET_THREAD_PRIORITY(priority)   #error "Replace with custom definition"
 Sets the priority for the thread. More...
 
#define GTS_SET_THIS_THREAD_NAME(name)   #error "Replace with custom definition"
 Sets a thread's name. More...
 
#define GTS_GET_THIS_THREAD_ID()   #error "Replace with custom definition"
 
#define GTS_GET_THIS_THREAD()   #error "Replace with custom definition"
 
#define GTS_SET_THIS_THREAD_GROUP_AFFINITY(groupId, affinitySet)   #error "Replace with custom definition"
 
#define GTS_YIELD_THREAD()   #error "Replace with custom definition"
 Yields the current thread to another thread. More...
 
#define GTS_THREAD_SLEEP(milliseconds)   #error "Replace with custom definition"
 Suspends the current thread for the specified time. More...
 
#define GTS_GET_HARDWARE_THREAD_COUNT()   #error "Replace with custom definition"
 Get the hardware thread ID and socked ID the calling thread is running on. More...
 
#define GTS_GET_CURRENT_PROCESSOR_ID(socketId, hwTid)   #error "Replace with custom definition"
 
#define GTS_CPU_CORE_INFO   #error "Replace with custom definition"
 A description of a CPU core. More...
 
#define GTS_SOCKET_CORE_INFO   #error "Replace with custom definition"
 A description of a socket. More...
 
#define GTS_NUMA_NODE_CORE_INFO   #error "Replace with custom definition"
 A description of a NUMA node. More...
 
#define GTS_PROCESSOR_GROUP_INFO   #error "Replace with custom definition"
 A description of a processor group. More...
 
#define GTS_SYSTEM_TOPOLOGY   #error "Replace with custom definition"
 A description of the system's processor topology. More...
 

Detailed Description

User defined wrappers for the OS thread API.

Macro Definition Documentation

◆ GTS_CPU_CORE_INFO

#define GTS_CPU_CORE_INFO   #error "Replace with custom definition"

A description of a CPU core.

Remarks
Required struct layout:
struct CpuCoreInfo
{
inline ~CpuCoreInfo()
{
delete[] pLogicalAffinityMasks;
}
uint32_t* pHardwareThreadIds = nullptr;
size_t hardwareThreadIdCount = 0;
uint8_t efficiencyClass = 0;
};

◆ GTS_CREATE_THREAD

#define GTS_CREATE_THREAD (   threadHandle,
  tid,
  func,
  arg,
  stackSize 
)    #error "Replace with custom definition"

Creates and launches a new thread of execution.

Remarks
Signature:
bool createThread(ThreadHandle& handle, ThreadId& tid, ThreadFunction func, void* arg, size_t stackSize)
Parameters
[out]threadHandleThe handle to the created thread.
[out]tidThe ID of the created thread.
funcThe function the thread will execute. Must have the signature: void (func)(void pArg).
argThe user defined argument that will be passed into func.
stackSizeThe stack size of the threads. 0 => default.
Returns
True on success, false on fail.

◆ GTS_DESTROY_THREAD

#define GTS_DESTROY_THREAD (   threadHandle)    #error "Replace with custom definition"

Frees a ThreadHandle.

Remarks
Signature:
bool destroy(ThreadHandle& handle)
Parameters
threadHandleThe thread to destroy.
Returns
True on success, false on fail.

◆ GTS_GET_HARDWARE_THREAD_COUNT

#define GTS_GET_HARDWARE_THREAD_COUNT ( )    #error "Replace with custom definition"

Get the hardware thread ID and socked ID the calling thread is running on.

Remarks
Signature:
uint32_t getHardwareThreadCount()
Returns
The number of HW threads in the system.
Remarks
Signature:
void getCurrentProcessorId(uint32_t& socketId, uint32_t& hwTid)
Parameters
[out]socketIdThe returned socket ID.
[out]priorityThe returned hardware thread ID.

◆ GTS_GET_THIS_THREAD

#define GTS_GET_THIS_THREAD ( )    #error "Replace with custom definition"
Remarks
Signature:
ThreadHandle getThisThread()
Returns
The calling thread's handle.

◆ GTS_GET_THIS_THREAD_ID

#define GTS_GET_THIS_THREAD_ID ( )    #error "Replace with custom definition"
Remarks
Signature:
ThreadId getThisThreadId()
Returns
The calling thread's ID.

◆ GTS_JOIN_THREAD

#define GTS_JOIN_THREAD (   threadHandle)    #error "Replace with custom definition"

Blocks until the thread exits.

Remarks
Signature:
bool join(ThreadHandle& handle)
Parameters
threadHandleThe thread to wait on.
Returns
True on success, false on fail.

◆ GTS_NUMA_NODE_CORE_INFO

#define GTS_NUMA_NODE_CORE_INFO   #error "Replace with custom definition"

A description of a NUMA node.

Remarks
Required struct layout:
struct NumaNodeInfo
{
~NumaNodeInfo()
{
delete[] pCoreInfoArray;
}
CpuCoreInfo* pCoreInfoArray = nullptr;
size_t coreInfoElementCount = 0;
size_t nodeId = SIZE_MAX;
};

◆ GTS_PROCESSOR_GROUP_INFO

#define GTS_PROCESSOR_GROUP_INFO   #error "Replace with custom definition"

A description of a processor group.

Remarks
Required struct layout:
struct ProcessorGroupInfo
{
~ProcessorGroupInfo()
{
delete[] pCoreInfoArray;
delete[] pNumaInfoArray;
delete[] pSocketInfoArray;
}
CpuCoreInfo* pCoreInfoArray = nullptr;
size_t coreInfoElementCount = 0;
NumaNodeInfo* pNumaInfoArray = nullptr;
size_t numaNodeInfoElementCount = 0;
SocketInfo* pSocketInfoArray = nullptr;
size_t socketInfoElementCount = 0;
uint32_t groupId;
};

◆ GTS_SET_THIS_THREAD_NAME

#define GTS_SET_THIS_THREAD_NAME (   name)    #error "Replace with custom definition"

Sets a thread's name.

Remarks
Signature:
void setThisThreadName(const char* name)
Parameters
nameThe name to set.

◆ GTS_SET_THREAD_PRIORITY [1/2]

#define GTS_SET_THREAD_PRIORITY (   priority)    #error "Replace with custom definition"

Sets the priority for the thread.

Remarks
Signature:
bool setPriority(ThreadId& tid, int32_t priority)
Parameters
threadHandleThe thread to apply the priority to.
priorityThe priority of the thread.
Returns
True on success, false on fail.

◆ GTS_SET_THREAD_PRIORITY [2/2]

#define GTS_SET_THREAD_PRIORITY (   tid,
  priority 
)    #error "Replace with custom definition"

Sets the priority for the thread.

Remarks
Signature:
bool setPriority(ThreadId& tid, int32_t priority)
Parameters
threadHandleThe thread to apply the priority to.
priorityThe priority of the thread.
Returns
True on success, false on fail.

◆ GTS_SOCKET_CORE_INFO

#define GTS_SOCKET_CORE_INFO   #error "Replace with custom definition"

A description of a socket.

Remarks
Required struct layout:
struct CpuSocketInfo
{
~CpuSocketInfo()
{
delete[] pCoreInfoArray;
}
CpuCoreInfo* pCoreInfoArray = nullptr;
size_t coreInfoElementCount = 0;
};

◆ GTS_SYSTEM_TOPOLOGY

#define GTS_SYSTEM_TOPOLOGY   #error "Replace with custom definition"

A description of the system's processor topology.

Remarks
Required struct layout:
struct SystemTopology
{
~SystemTopology()
{
delete[] pGroupInfoArray;
}
ProcessorGroupInfo* pGroupInfoArray = nullptr;
size_t groupInfoElementCount = 0;
};

◆ GTS_THREAD_AFFINITY_SET_TYPE

#define GTS_THREAD_AFFINITY_SET_TYPE   #error "Replace with custom definition"

A description of an CPU affinity set for a threa.

Remarks
Required struct layout:
struct AffinitySet
{
void set(uint32_t cpuId);
void combine(AffinitySet const& other);
bool empty() const;
};

◆ GTS_THREAD_SLEEP

#define GTS_THREAD_SLEEP (   milliseconds)    #error "Replace with custom definition"

Suspends the current thread for the specified time.

Remarks
Signature:
void sleep(uint32_t milliseconds)
Parameters
millisecondsThe amount of time to suspend for.

◆ GTS_YIELD_THREAD

#define GTS_YIELD_THREAD ( )    #error "Replace with custom definition"

Yields the current thread to another thread.

Remarks
Signature:
void yield()