15#include <unordered_set>
76template<std::
integral T>
88 using FreeIdList = std::priority_queue<value_type, std::vector<value_type>, std::greater<value_type>>;
103 if (_freeIds.empty())
141 if (_freedIds.contains(
id))
146 if (_activeCount == 0)
149 if (_nextId ==
id + 1)
154 _freedIds.insert(
id);
184 for (
auto i = _nextId; i < id; ++i)
193 B_ASSERT(_freedIds.contains(
id),
"ID {} is already in use",
id);
200 while (!_freeIds.empty())
202 auto const v = _freeIds.top();
235 uint64_t _activeCount = 0;
237 std::unordered_set<value_type> _freedIds;
Exception utilities for dfx (source-location aware exceptions, nested stacks, and safe invocation hel...
#define B_ASSERT(expr, msg,...)
Assert-like check that throws an dfx::Utils::Exception on failure.
Definition Exception.hpp:251
ID allocator that can recycle released identifiers.
Definition RecyclableIdAllocator.hpp:78
void reset() noexcept
Reset the allocator to its initial state.
Definition RecyclableIdAllocator.hpp:225
void release(value_type id)
Release an identifier back to the allocator.
Definition RecyclableIdAllocator.hpp:134
void reserve(value_type id)
Mark an identifier as in-use without returning it from next().
Definition RecyclableIdAllocator.hpp:179
T value_type
Type used for allocated identifiers.
Definition RecyclableIdAllocator.hpp:81
value_type next() noexcept
Allocate and return an identifier.
Definition RecyclableIdAllocator.hpp:99
Definition SystemConfigCommandHandler.hpp:15