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

Classes

struct  gts::numericLimits< T >
 The root template for numeric limits. More...
 
struct  gts::numericLimits< uint32_t >
 The numeric limits for uint32_t. More...
 
struct  gts::numericLimits< uint64_t >
 The numeric limits for uint64_t. More...
 
struct  gts::numericLimits< int32_t >
 The numeric limits for int32_t. More...
 
struct  gts::numericLimits< int64_t >
 The numeric limits for int64_t. More...
 
struct  gts::IsPow2< T, val >
 A power of 2 type trait. More...
 
class  gts::OwnedId
 An ID for owned objects. It indicates the owner's ID, an ID local to the owner, and an overall unique ID. More...
 
struct  gts::MurmurHash< TKey >
 The base murmur hash functor. More...
 
struct  gts::MurmurHash< float >
 The float specialized murmur hash functor. More...
 
struct  gts::MurmurHash< double >
 The double specialized murmur hash functor. More...
 
struct  gts::MurmurHash< char * >
 The c-string specialized murmur hash functor. More...
 
struct  gts::MurmurHash< TKey * >
 The pointer specialized murmur hash functor. More...
 

Typedefs

using gts::IdType = uint32_t
 The type used to identify an object.
 
using gts::SubIdType = uint16_t
 The sub type stored in IdType.
 

Functions

template<typename T >
constexpr T gts::gtsMax (T const &lhs, T const &rhs)
 Calculates the max of lhs and rhs. More...
 
template<typename T >
constexpr T gts::gtsMin (T const &lhs, T const &rhs)
 Calculates the min of lhs and rhs. More...
 
template<typename T >
constexpr bool gts::isPow2 (T value)
 Checks if value is a power of 2. More...
 
constexpr GTS_INLINE uint16_t gts::nextPow2 (uint16_t value)
 Calculates the next 16-bit power of 2 if value is not a power of 2. More...
 
constexpr GTS_INLINE uint32_t gts::nextPow2 (uint32_t value)
 Calculates the next 32-bit power of 2 if value is not a power of 2. More...
 
constexpr GTS_INLINE uint64_t gts::nextPow2 (uint64_t value)
 Calculates the next 64-bit power of 2 if value is not a power of 2. More...
 
template<typename TInt >
GTS_INLINE TInt gts::log2i (TInt const &integral)
 Calculates log2 a integer. More...
 
template<>
GTS_INLINE int64_t gts::log2i (int64_t const &integral)
 Specialization to calculate the log2 a signed 64-bit integer. More...
 
template<>
GTS_INLINE uint64_t gts::log2i (uint64_t const &integral)
 Specialization to calculate the log2 a unsigned 64-bit integer. More...
 
GTS_INLINE uint32_t gts::fastRand (uint32_t &state)
 Generates a pseudo random number using xor shift algorithm on 'state'. More...
 
GTS_INLINE bool gts::isAligned (void *ptr, size_t alignmentPow2)
 Checks if ptr is aligned to the boundary alignmentPow2. More...
 
GTS_INLINE uintptr_t gts::alignDownTo (uintptr_t ptr, size_t alignment)
 Aligns ptr down to the next alignment boundary. More...
 
GTS_INLINE uintptr_t gts::alignUpTo (uintptr_t ptr, size_t alignment)
 Aligns ptr up to the next alignment boundary. More...
 
GTS_INLINE uint32_t gts::murmur_hash3 (uint32_t key)
 
GTS_INLINE uint64_t gts::murmur_hash3 (uint64_t key)
 
GTS_INLINE uint32_t gts::murmur_hash3 (const void *key, uint32_t len, uint32_t seed=12345)
 
template<typename TResult , typename TFunc , typename... TArgs>
GTS_INLINE TResult gts::invoke (TFunc &&func, TArgs &&... args)
 A simple function invoker.
 
template<typename Value , typename TCompareFunc >
GTS_INLINE void gts::insertionSort (Value *values, size_t numValues, TCompareFunc fcnComp)
 Simple insertion sort implementation.
 

Variables

constexpr IdType gts::UNKNOWN_UID = UINT32_MAX
 The value of an unknown IdType.
 
constexpr SubIdType gts::UNKNOWN_SUBID = UINT16_MAX
 The value of an unknown SubIdType.
 

Detailed Description

A set of utility functions.

Function Documentation

◆ alignDownTo()

GTS_INLINE uintptr_t gts::alignDownTo ( uintptr_t  ptr,
size_t  alignment 
)

Aligns ptr down to the next alignment boundary.

Returns
An aligned address.

◆ alignUpTo()

GTS_INLINE uintptr_t gts::alignUpTo ( uintptr_t  ptr,
size_t  alignment 
)

Aligns ptr up to the next alignment boundary.

Returns
An aligned address.

◆ fastRand()

GTS_INLINE uint32_t gts::fastRand ( uint32_t &  state)

Generates a pseudo random number using xor shift algorithm on 'state'.

Returns
A pseudo random number.

◆ gtsMax()

template<typename T >
constexpr T gts::gtsMax ( T const &  lhs,
T const &  rhs 
)
constexpr

Calculates the max of lhs and rhs.

Returns
The maximum value.

◆ gtsMin()

template<typename T >
constexpr T gts::gtsMin ( T const &  lhs,
T const &  rhs 
)
constexpr

Calculates the min of lhs and rhs.

Returns
The minimum value.

◆ isAligned()

GTS_INLINE bool gts::isAligned ( void *  ptr,
size_t  alignmentPow2 
)

Checks if ptr is aligned to the boundary alignmentPow2.

Returns
True if aligned, false otherwise.

◆ isPow2()

template<typename T >
constexpr bool gts::isPow2 ( value)
constexpr

Checks if value is a power of 2.

Returns
True if value is a power of 2.

◆ log2i() [1/3]

template<>
GTS_INLINE int64_t gts::log2i ( int64_t const &  integral)

Specialization to calculate the log2 a signed 64-bit integer.

Returns
Log2 of integral.

◆ log2i() [2/3]

template<typename TInt >
GTS_INLINE TInt gts::log2i ( TInt const &  integral)

Calculates log2 a integer.

Returns
Log2 of integral.

◆ log2i() [3/3]

template<>
GTS_INLINE uint64_t gts::log2i ( uint64_t const &  integral)

Specialization to calculate the log2 a unsigned 64-bit integer.

Returns
Log2 of integral.

◆ murmur_hash3() [1/3]

GTS_INLINE uint32_t gts::murmur_hash3 ( const void *  key,
uint32_t  len,
uint32_t  seed = 12345 
)
Returns
The murmur hash of a string.

◆ murmur_hash3() [2/3]

GTS_INLINE uint32_t gts::murmur_hash3 ( uint32_t  key)
Returns
The murmur hash of a 32-bit key.

◆ murmur_hash3() [3/3]

GTS_INLINE uint64_t gts::murmur_hash3 ( uint64_t  key)
Returns
The murmur hash of a 64-bit key.

◆ nextPow2() [1/3]

constexpr GTS_INLINE uint16_t gts::nextPow2 ( uint16_t  value)
constexpr

Calculates the next 16-bit power of 2 if value is not a power of 2.

Returns
The next power of 2 after value or value.

◆ nextPow2() [2/3]

constexpr GTS_INLINE uint32_t gts::nextPow2 ( uint32_t  value)
constexpr

Calculates the next 32-bit power of 2 if value is not a power of 2.

Returns
The next power of 2 after value or value.

◆ nextPow2() [3/3]

constexpr GTS_INLINE uint64_t gts::nextPow2 ( uint64_t  value)
constexpr

Calculates the next 64-bit power of 2 if value is not a power of 2.

Returns
The next power of 2 after value or value.