Skip to content

Commit

Permalink
Merge pull request #918 from redboltz/add_running_in_this_thread
Browse files Browse the repository at this point in the history
Added running_in_this_thread() wrapper.
  • Loading branch information
redboltz authored Mar 8, 2022
2 parents c3dfab2 + 4169247 commit f1ebfbf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/mqtt/null_strand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct null_strand {
}
);
}
bool running_in_this_thread() const noexcept { return false; }
void on_work_started() const noexcept {}
void on_work_finished() const noexcept {}
as::io_context& context() noexcept{ return ioc_; }
Expand Down
4 changes: 4 additions & 0 deletions include/mqtt/tcp_endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class tcp_endpoint : public socket {
);
}

MQTT_ALWAYS_INLINE bool running_in_this_thread() const override final {
return strand_.running_in_this_thread();
}

MQTT_ALWAYS_INLINE as::ip::tcp::socket::lowest_layer_type& lowest_layer() override final {
return tcp_.lowest_layer();
}
Expand Down
1 change: 1 addition & 0 deletions include/mqtt/type_erased_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class socket {
virtual void post(std::function<void()>) = 0;
virtual void dispatch(std::function<void()>) = 0;
virtual void defer(std::function<void()>) = 0;
virtual bool running_in_this_thread() const = 0;
virtual as::ip::tcp::socket::lowest_layer_type& lowest_layer() = 0;
virtual any native_handle() = 0;
virtual void clean_shutdown_and_close(boost::system::error_code&) = 0;
Expand Down
4 changes: 4 additions & 0 deletions include/mqtt/ws_endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class ws_endpoint : public socket {
);
}

MQTT_ALWAYS_INLINE bool running_in_this_thread() const override final {
return strand_.running_in_this_thread();
}

#if BOOST_VERSION >= 107000

MQTT_ALWAYS_INLINE as::ip::tcp::socket::lowest_layer_type& lowest_layer() override final {
Expand Down

0 comments on commit f1ebfbf

Please sign in to comment.