Skip to content

Commit

Permalink
Merge pull request #907 from redboltz/add_dispatch_wrapper
Browse files Browse the repository at this point in the history
Added dispatch wrapper.
  • Loading branch information
redboltz authored Nov 30, 2021
2 parents 96743d4 + e0e03ad commit b4caab7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/mqtt/tcp_endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class tcp_endpoint : public socket {
);
}

MQTT_ALWAYS_INLINE void dispatch(std::function<void()> handler) override final {
as::dispatch(
strand_,
force_move(handler)
);
}

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 @@ -26,6 +26,7 @@ class socket {
virtual void async_write(std::vector<as::const_buffer>, std::function<void(error_code, std::size_t)>) = 0;
virtual std::size_t write(std::vector<as::const_buffer>, boost::system::error_code&) = 0;
virtual void post(std::function<void()>) = 0;
virtual void dispatch(std::function<void()>) = 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
7 changes: 7 additions & 0 deletions include/mqtt/ws_endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ class ws_endpoint : public socket {
);
}

MQTT_ALWAYS_INLINE void dispatch(std::function<void()> handler) override final {
as::dispatch(
strand_,
force_move(handler)
);
}

#if BOOST_VERSION >= 107000

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

0 comments on commit b4caab7

Please sign in to comment.