Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added running_in_this_thread() wrapper. #918

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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