7#if !defined(ASYNC_MQTT_UTIL_PACKET_ID_MANAGER_HPP)
8#define ASYNC_MQTT_UTIL_PACKET_ID_MANAGER_HPP
12#include <async_mqtt/util/value_allocator.hpp>
16template <
typename PacketId>
17class packet_id_manager {
18 using packet_id_type = PacketId;
30 std::optional<packet_id_type> acquire_unique_id() {
31 return va_.allocate();
41 bool register_id(packet_id_type packet_id) {
42 return va_.use(packet_id);
49 bool is_used_id(packet_id_type packet_id)
const {
50 return va_.is_used(packet_id);
59 void release_id(packet_id_type packet_id) {
60 va_.deallocate(packet_id);
71 value_allocator<packet_id_type> va_ {1, std::numeric_limits<packet_id_type>::max()};