Fixed-capacity SMP-safe ID allocator backed by a bitmap.
More...
|
| auto | alloc () noexcept -> std::optional< u32 > |
| | Allocate the lowest available ID.
|
|
auto | count () const noexcept -> u32 |
| | Number of currently allocated IDs.
|
|
auto | free (u32 id) noexcept -> void |
| | Free a previously allocated ID.
|
|
auto | is_allocated (u32 id) const noexcept -> bool |
| | Check if an ID is currently allocated.
|
|
auto | reserve (u32 n) noexcept -> void |
| | Reserve IDs [0, n). These will never be returned by alloc().
|
|
|
static constexpr u32 | capacity = static_cast<u32>(MaxIds) |
| | Maximum capacity.
|
template<usize MaxIds>
class lib::id_allocator< MaxIds >
Fixed-capacity SMP-safe ID allocator backed by a bitmap.
- Template Parameters
-
| MaxIds | Maximum number of IDs (0 to MaxIds-1). |
◆ alloc()
template<usize MaxIds>
|
|
inlinenodiscardexportnoexcept |
Allocate the lowest available ID.
- Returns
- The allocated ID, or nullopt if all IDs exhausted.
The documentation for this class was generated from the following file: