7#if !defined(ASYNC_MQTT_PACKET_ID_MANAGER_HPP)
8#define ASYNC_MQTT_PACKET_ID_MANAGER_HPP
10#include <async_mqtt/util/value_allocator.hpp>
14template <
typename PacketId>
15class packet_id_manager {
16 using packet_id_type = PacketId;
28 optional<packet_id_type> acquire_unique_id() {
29 return va_.allocate();
39 bool register_id(packet_id_type packet_id) {
40 return va_.use(packet_id);
47 bool is_used_id(packet_id_type packet_id)
const {
48 return va_.is_used(packet_id);
57 void release_id(packet_id_type packet_id) {
58 va_.deallocate(packet_id);
69 value_allocator<packet_id_type> va_ {1, std::numeric_limits<packet_id_type>::max()};