dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
MonotonicIdAllocator.hpp
1// SPDX-FileCopyrightText: 2025 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <concepts>
13
14namespace dfx::Utils
15{
50template<std::integral T>
52{
53public:
55 using value_type = T;
56
57public:
64 value_type next() noexcept
65 {
66 return _id++;
67 }
68
77 void reset() noexcept
78 {
79 _id = 0;
80 }
81
82private:
83 value_type _id = 0;
84};
85} // !namespace dfx::Utils
Monotonically increasing ID allocator.
Definition MonotonicIdAllocator.hpp:52
T value_type
Type used for allocated identifiers.
Definition MonotonicIdAllocator.hpp:55
void reset() noexcept
Reset the allocator counter back to zero.
Definition MonotonicIdAllocator.hpp:77
value_type next() noexcept
Allocate and return the next identifier.
Definition MonotonicIdAllocator.hpp:64
Definition SystemConfigCommandHandler.hpp:15