Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::mt::JobHandle Struct Referencefinal

Packed identifier for a job-pool slot, generation, and priority. More...

#include <jobhandle.h>

Public Types

using JobSizeType = std::conditional_t<(AllBits > 32), uint64_t, uint32_t >
 Integer type large enough to hold all packed fields.
 

Public Member Functions

 JobHandle ()
 Creates the null job handle.
 
 JobHandle (JobId id, JobGenId gen, JobGenId prio)
 Creates a handle from its component fields.
 
 JobHandle (uint32_t value)
 Creates a handle from its packed representation.
 
 JobHandle (JobHandle &&) noexcept=default
 
 JobHandle (const JobHandle &)=default
 
JobHandleoperator= (JobHandle &&) noexcept=default
 
JobHandleoperator= (const JobHandle &)=default
 
GAIA_NODISCARD constexpr bool operator== (const JobHandle &other) const noexcept
 Compares packed handle values.
 
GAIA_NODISCARD constexpr bool operator!= (const JobHandle &other) const noexcept
 Compares packed handle values.
 
GAIA_NODISCARD auto id () const
 Returns the job-pool slot identifier.
 
GAIA_NODISCARD auto gen () const
 Returns the slot generation.
 
GAIA_NODISCARD auto prio () const
 Returns the encoded priority bit.
 
GAIA_NODISCARD auto value () const
 Returns the packed handle representation.
 

Static Public Attributes

static constexpr JobInternalType IdBits = 20
 Number of bits reserved for the slot identifier.
 
static constexpr JobInternalType GenBits = 11
 Number of bits reserved for the generation.
 
static constexpr JobInternalType PrioBits = 1
 Number of bits reserved for the priority.
 
static constexpr JobInternalType AllBits = IdBits + GenBits + PrioBits
 Total number of bits used by a packed handle.
 
static constexpr JobInternalType IdMask = (uint32_t)(uint64_t(1) << IdBits) - 1
 Mask selecting the slot identifier.
 
static constexpr JobInternalType GenMask = (uint32_t)(uint64_t(1) << GenBits) - 1
 Mask selecting the unshifted generation.
 
static constexpr JobInternalType PrioMask = (uint32_t)(uint64_t(1) << PrioBits) - 1
 Mask selecting the unshifted priority.
 

Detailed Description

Packed identifier for a job-pool slot, generation, and priority.

Constructor & Destructor Documentation

◆ JobHandle() [1/2]

gaia::mt::JobHandle::JobHandle ( JobId  id,
JobGenId  gen,
JobGenId  prio 
)
inline

Creates a handle from its component fields.

Parameters
idJob-pool slot identifier.
genSlot generation.
prioEncoded priority bit.

◆ JobHandle() [2/2]

gaia::mt::JobHandle::JobHandle ( uint32_t  value)
inlineexplicit

Creates a handle from its packed representation.

Parameters
valuePacked handle value.

Member Function Documentation

◆ gen()

GAIA_NODISCARD auto gaia::mt::JobHandle::gen ( ) const
inline

Returns the slot generation.

Returns
Generation value.

◆ id()

GAIA_NODISCARD auto gaia::mt::JobHandle::id ( ) const
inline

Returns the job-pool slot identifier.

Returns
Slot identifier.

◆ operator!=()

GAIA_NODISCARD constexpr bool gaia::mt::JobHandle::operator!= ( const JobHandle other) const
inlineconstexprnoexcept

Compares packed handle values.

Parameters
otherHandle to compare.
Returns
True when the handles differ.

◆ operator==()

GAIA_NODISCARD constexpr bool gaia::mt::JobHandle::operator== ( const JobHandle other) const
inlineconstexprnoexcept

Compares packed handle values.

Parameters
otherHandle to compare.
Returns
True when both handles are identical.

◆ prio()

GAIA_NODISCARD auto gaia::mt::JobHandle::prio ( ) const
inline

Returns the encoded priority bit.

Returns
Priority bit.

◆ value()

GAIA_NODISCARD auto gaia::mt::JobHandle::value ( ) const
inline

Returns the packed handle representation.

Returns
Packed value.

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