7#if !defined(ASYNC_MQTT_NULL_STRAND_HPP)
8#define ASYNC_MQTT_NULL_STRAND_HPP
13#include <boost/asio.hpp>
15#include <async_mqtt/type.hpp>
19namespace as = boost::asio;
21template <
typename Executor>
24 using inner_executor_type = Executor;
26 null_strand(Executor exe) noexcept
30 null_strand() noexcept = default;
31 null_strand(null_strand const&) noexcept = default;
32 null_strand(null_strand&&) noexcept = default;
33 template <typename OtherExecutor>
34 null_strand(null_strand<OtherExecutor> const& other) noexcept
38 template <
typename OtherExecutor>
39 null_strand(null_strand<OtherExecutor>&& other) noexcept
40 :exe_{std::move(other.exe_)}
44 null_strand<Executor>& operator=(null_strand
const& other)
noexcept {
48 null_strand<Executor>& operator=(null_strand&& other)
noexcept {
49 exe_ = std::move(other.exe_);
52 template <
typename OtherExecutor>
53 null_strand<Executor>& operator=(null_strand<OtherExecutor>
const& other)
noexcept {
57 template <
typename OtherExecutor>
58 null_strand<Executor>& operator=(null_strand<OtherExecutor>&& other)
noexcept {
59 exe_ = std::move(other.exe_);
69 Allocator
const& a)
const {
75 std::forward<Function>(f)
86 Allocator
const& a)
const {
92 std::forward<Function>(f)
103 Allocator
const& a)
const {
109 std::forward<Function>(f)
115 void on_work_started() const noexcept {
117 void on_work_finished() const noexcept {
119 bool running_in_this_thread() const noexcept {
123 template <
typename Function>
124 void execute(Function&& f)
const {
125 exe_.execute(std::forward<Function>(f));
129 as::execution_context& context() const noexcept {
130 return exe_.context();
133 inner_executor_type get_inner_executor() const noexcept {
137 friend bool operator==(
138 null_strand<Executor>
const& lhs,
139 null_strand<Executor>
const& rhs
141 return lhs.exe_ == rhs.exe_;
143 friend bool operator!=(
144 null_strand<Executor>
const& lhs,
145 null_strand<Executor>
const& rhs
147 return lhs.exe_ != rhs.exe_;
151 inner_executor_type exe_;