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 bool immediate_executable()
const {
34 return !working_ && queue_.stopped();
37 template <
typename CompletionToken>
38 void post(CompletionToken&& token) {
41 std::forward<CompletionToken>(token)
43 if (immediate_executable()) {
49 bool stopped()
const {
50 return queue_.stopped();
53 std::size_t poll_one() {
55 if (queue_.stopped()) queue_.restart();
56 return queue_.poll_one();
61 if (queue_.stopped()) queue_.restart();
66 as::io_context queue_{BOOST_ASIO_CONCURRENCY_HINT_UNSAFE};
67 bool working_ =
false;
68 optional<as::executor_work_guard<as::io_context::executor_type>> guard_;