Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::UUIDGenerator Class Reference

Centralized generator for 64-bit tagged UUIDs. More...

#include <UUIDGenerator.h>

Static Public Member Functions

static void Initialize () noexcept
 Initializes the internal RNG engine using platform entropy.
static u64 Generate (UUIDTag tag) noexcept
 Generates a new 64-bit UUID with the specified tag.

Detailed Description

Centralized generator for 64-bit tagged UUIDs.

This class provides a thread-safe, deterministic (unless seeded with platform entropy) way to create unique 64-bit identifiers. Each UUID carries a 4-bit tag in its high bits, ensuring no overlap between different domains. The remaining 60 bits are filled with pseudorandom data from a dedicated PCG32 engine.

Usage:

  • Call UUIDGenerator::Initialize() once at engine startup to seed the generator.
  • Call UUIDGenerator::Generate(tag) to obtain a new, non-zero UUID with the specified tag.

Member Function Documentation

◆ Generate()

u64 Raven::UUIDGenerator::Generate ( UUIDTag tag)
staticnoexcept

Generates a new 64-bit UUID with the specified tag.

This method asserts that Initialize() has been called. It then:

  1. Draws two 32-bit outputs from the PCG32 engine and combines them into 64 bits.
  2. Clears the upper tag bits and inserts the requested UUIDTag.
  3. Repeats if the resulting value is zero, reserving zero as an invalid sentinel.
Parameters
tagThe domain tag to embed in the UUID.
Returns
A non-zero 64-bit identifier with the high 4 bits set to tag.

◆ Initialize()

void Raven::UUIDGenerator::Initialize ( )
staticnoexcept

Initializes the internal RNG engine using platform entropy.

This method must be called exactly once before any calls to Generate(). It seeds the private PCG32 engine with two 64-bit values obtained from Crux::Entropy::GetSeedPair(), which sources high-quality entropy.

Thread-safe via internal mutex; subsequent calls have no effect.


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