7#if !defined(ASYNC_MQTT_UTIL_IOC_QUEUE_HPP)
8#define ASYNC_MQTT_UTIL_IOC_QUEUE_HPP
10#include <boost/asio.hpp>
12#include <async_mqtt/util/optional.hpp>
16namespace as = boost::asio;
26 guard_.emplace(queue_.get_executor());
33 template <
typename CompletionToken>
34 void post(CompletionToken&& token) {
37 std::forward<CompletionToken>(token)
39 if (!working_ && queue_.stopped()) {
45 bool stopped()
const {
46 return queue_.stopped();
49 std::size_t poll_one() {
51 if (queue_.stopped()) queue_.restart();
52 return queue_.poll_one();
57 if (queue_.stopped()) queue_.restart();
62 as::io_context queue_;
63 bool working_ =
false;
64 optional<as::executor_work_guard<as::io_context::executor_type>> guard_;