EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
echomap::IDAllocator< typename > Class Template Reference

Provides a simple thread-safe runtime ID generator for Object managers. More...

#include <IDAllocator.hpp>

Static Public Member Functions

static id_type allocate () noexcept
 Allocate the next ID.

Static Public Attributes

static constexpr id_type invalid_id = std::numeric_limits<id_type>::max()
 Sentinel ID used by invalidated (moved-from) objects.

Static Private Attributes

static std::atomic< id_type > next_id = 0

Detailed Description

template<typename>
class echomap::IDAllocator< typename >

Provides a simple thread-safe runtime ID generator for Object managers.

Definition at line 27 of file IDAllocator.hpp.

Member Function Documentation

◆ allocate()

template<typename>
id_type echomap::IDAllocator< typename >::allocate ( )
inlinestaticnodiscardnoexcept

Allocate the next ID.

Returns
The next ID.
Precondition
The datatype will be sufficient to store the subsequent ID following allocation.

Definition at line 43 of file IDAllocator.hpp.

44 {
45 const auto allocated = next_id.fetch_add(1, std::memory_order_relaxed);
47 return allocated;
48 }
Provides a simple thread-safe runtime ID generator for Object managers.
static constexpr id_type invalid_id
Sentinel ID used by invalidated (moved-from) objects.

Member Data Documentation

◆ invalid_id

template<typename>
id_type echomap::IDAllocator< typename >::invalid_id = std::numeric_limits<id_type>::max()
staticconstexpr

Sentinel ID used by invalidated (moved-from) objects.

This value is reserved and must never be returned by allocate.

Definition at line 35 of file IDAllocator.hpp.

◆ next_id

template<typename>
std::atomic<id_type> echomap::IDAllocator< typename >::next_id = 0
inlinestaticprivate

Definition at line 51 of file IDAllocator.hpp.


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