EchoMap
2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Toggle main menu visibility
Loading...
Searching...
No Matches
IDAllocator.hpp
Go to the documentation of this file.
1
9
10
#ifndef ECHOMAP_IDALLOCATOR_HPP
11
#define ECHOMAP_IDALLOCATOR_HPP
12
13
#include <
atomic
>
14
#include <
cassert
>
15
#include <
cstdint
>
16
#include <
limits
>
17
18
namespace
echomap
19
{
20
21
using
id_type = std::uint64_t;
22
26
template
<
typename
>
27
class
IDAllocator
28
{
29
public
:
35
static
constexpr
id_type
invalid_id
=
std::numeric_limits<id_type>::max
();
36
43
[[nodiscard]]
static
id_type
allocate
() noexcept
44
{
45
const
auto
allocated = next_id.fetch_add(1, std::memory_order_relaxed);
46
assert(allocated !=
invalid_id
);
47
return
allocated;
48
}
49
50
private
:
51
inline
static
std::atomic<id_type>
next_id = 0;
52
};
53
54
}
// namespace echomap
55
56
#endif
// ECHOMAP_IDALLOCATOR_HPP
atomic
cassert
echomap::IDAllocator
Provides a simple thread-safe runtime ID generator for Object managers.
Definition
IDAllocator.hpp:28
echomap::IDAllocator::invalid_id
static constexpr id_type invalid_id
Sentinel ID used by invalidated (moved-from) objects.
Definition
IDAllocator.hpp:35
echomap::IDAllocator::allocate
static id_type allocate() noexcept
Allocate the next ID.
Definition
IDAllocator.hpp:43
cstdint
limits
std::numeric_limits::max
T max(T... args)
echomap
The main EchoMap outermost namespace for all non-exported symbols.
Definition
ActionController.hpp:20
src
objects
IDAllocator.hpp
Generated by
1.17.0