Skip to content

Commit

Permalink
Merge pull request #952 from redboltz/fix_executor_as_strand
Browse files Browse the repository at this point in the history
Removed old TS code.
  • Loading branch information
redboltz authored Oct 6, 2022
2 parents 0b6a831 + f04c68b commit 0d9e718
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 140 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/gha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ jobs:
export CFLAGS=${S_CFLAGS} && export CXXFLAGS=${S_CXXFLAGS} && export LDFLAGS=${S_LDFLAGS}
[ ${{ matrix.pattern }} == 0 ] || [ ${{ matrix.pattern }} == 4 ] || [ ${{ matrix.pattern }} == 5 ] || [ ${{ matrix.pattern }} == 6 ] || [ ${{ matrix.pattern }} == 7 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=ON -DMQTT_TEST_2=ON -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=OFF -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=ON -DMQTT_STD_ANY=OFF -DMQTT_STD_OPTIONAL=OFF -DMQTT_STD_VARIANT=OFF -DMQTT_STD_STRING_VIEW=OFF -DMQTT_STD_SHARED_PTR_ARRAY=OFF -DMQTT_NO_TS_EXECUTORS=OFF"
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=ON -DMQTT_TEST_2=ON -DMQTT_TEST_3=ON -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=OFF -DMQTT_STD_OPTIONAL=OFF -DMQTT_STD_VARIANT=OFF -DMQTT_STD_STRING_VIEW=OFF -DMQTT_STD_SHARED_PTR_ARRAY=OFF -DMQTT_NO_TS_EXECUTORS=OFF"
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=ON -DMQTT_TEST_5=ON -DMQTT_TEST_6=ON -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF -DMQTT_NO_TS_EXECUTORS=OFF"
[ ${{ matrix.pattern }} == 3 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=ON -DMQTT_BUILD_EXAMPLES=ON -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF -DMQTT_NO_TS_EXECUTORS=OFF"
[ ${{ matrix.pattern }} == 4 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=ON -DMQTT_TEST_2=ON -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=OFF -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=ON -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=ON -DMQTT_NO_TS_EXECUTORS=ON"
[ ${{ matrix.pattern }} == 5 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=ON -DMQTT_TEST_4=ON -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=OFF -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF -DMQTT_NO_TS_EXECUTORS=OFF"
[ ${{ matrix.pattern }} == 6 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=ON -DMQTT_TEST_6=ON -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF -DMQTT_NO_TS_EXECUTORS=OFF"
[ ${{ matrix.pattern }} == 7 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=ON -DMQTT_BUILD_EXAMPLES=ON -DMQTT_USE_TLS=ON -DMQTT_USE_WS=OFF -DMQTT_USE_STR_CHECK=OFF -DMQTT_USE_LOG=ON -DMQTT_STD_ANY=OFF -DMQTT_STD_OPTIONAL=OFF -DMQTT_STD_VARIANT=OFF -DMQTT_STD_STRING_VIEW=OFF -DMQTT_STD_SHARED_PTR_ARRAY=OFF -DMQTT_NO_TS_EXECUTORS=OFF"
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=ON -DMQTT_TEST_2=ON -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=OFF -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=ON -DMQTT_STD_ANY=OFF -DMQTT_STD_OPTIONAL=OFF -DMQTT_STD_VARIANT=OFF -DMQTT_STD_STRING_VIEW=OFF -DMQTT_STD_SHARED_PTR_ARRAY=OFF"
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=ON -DMQTT_TEST_2=ON -DMQTT_TEST_3=ON -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=OFF -DMQTT_STD_OPTIONAL=OFF -DMQTT_STD_VARIANT=OFF -DMQTT_STD_STRING_VIEW=OFF -DMQTT_STD_SHARED_PTR_ARRAY=OFF"
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=ON -DMQTT_TEST_5=ON -DMQTT_TEST_6=ON -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF"
[ ${{ matrix.pattern }} == 3 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=ON -DMQTT_BUILD_EXAMPLES=ON -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF"
[ ${{ matrix.pattern }} == 4 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=ON -DMQTT_TEST_2=ON -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=OFF -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=ON -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=ON"
[ ${{ matrix.pattern }} == 5 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=ON -DMQTT_TEST_4=ON -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=OFF -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF"
[ ${{ matrix.pattern }} == 6 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=ON -DMQTT_TEST_6=ON -DMQTT_TEST_7=OFF -DMQTT_BUILD_EXAMPLES=OFF -DMQTT_USE_TLS=ON -DMQTT_USE_WS=ON -DMQTT_USE_STR_CHECK=ON -DMQTT_USE_LOG=OFF -DMQTT_STD_ANY=ON -DMQTT_STD_OPTIONAL=ON -DMQTT_STD_VARIANT=ON -DMQTT_STD_STRING_VIEW=ON -DMQTT_STD_SHARED_PTR_ARRAY=OFF"
[ ${{ matrix.pattern }} == 7 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++ -DMQTT_CODECOV=ON -DMQTT_TEST_1=OFF -DMQTT_TEST_2=OFF -DMQTT_TEST_3=OFF -DMQTT_TEST_4=OFF -DMQTT_TEST_5=OFF -DMQTT_TEST_6=OFF -DMQTT_TEST_7=ON -DMQTT_BUILD_EXAMPLES=ON -DMQTT_USE_TLS=ON -DMQTT_USE_WS=OFF -DMQTT_USE_STR_CHECK=OFF -DMQTT_USE_LOG=ON -DMQTT_STD_ANY=OFF -DMQTT_STD_OPTIONAL=OFF -DMQTT_STD_VARIANT=OFF -DMQTT_STD_STRING_VIEW=OFF -DMQTT_STD_SHARED_PTR_ARRAY=OFF"
echo "begin"
echo ${{env.BOOST_ROOT}}
Expand Down
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ OPTION(MQTT_STD_STRING_VIEW "Use std::string_view from C++17 instead of boost::s
OPTION(MQTT_STD_ANY "Use std::any from C++17 instead of boost::any" OFF)
OPTION(MQTT_STD_SHARED_PTR_ARRAY "Use std::shared_ptr<char[]> from C++17 instead of boost::shared_ptr<char[]>" OFF)
OPTION(MQTT_DISABLE_LIBSTDCXX_TUPLE_ANY_WORKAROUND "std::tuple<std::any> workaround for libstdc++" OFF)
OPTION(MQTT_NO_TS_EXECUTORS "Use standard executors instead of Networking TS-style executors" OFF)

IF (POLICY CMP0074)
CMAKE_POLICY(SET CMP0074 NEW)
Expand Down Expand Up @@ -88,13 +87,6 @@ ELSE ()
MESSAGE (STATUS "std::tuple<std::any> workaround for libstdc++ enabled")
ENDIF ()

IF (MQTT_NO_TS_EXECUTORS)
MESSAGE (STATUS "Using standard executors instead of Networking TS-style executors")
ELSE ()
MESSAGE (STATUS "Using Networking TS-style executors instead of standard executors")
ENDIF ()


IF ( MQTT_STD_VARIANT
OR MQTT_STD_OPTIONAL
OR MQTT_STD_ANY
Expand Down
1 change: 0 additions & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} INTERFACE $<$<BOOL:${MQTT_STD_ANY}>:M
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} INTERFACE $<$<BOOL:${MQTT_STD_STRING_VIEW}>:MQTT_STD_STRING_VIEW>)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} INTERFACE $<$<BOOL:${MQTT_STD_SHARED_PTR_ARRAY}>:MQTT_STD_SHARED_PTR_ARRAY>)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} INTERFACE $<$<BOOL:${MQTT_DISABLE_LIBSTDCXX_TUPLE_ANY_WORKAROUND}>:MQTT_DISABLE_LIBSTDCXX_TUPLE_ANY_WORKAROUND>)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} INTERFACE $<$<BOOL:${MQTT_NO_TS_EXECUTORS}>:MQTT_NO_TS_EXECUTORS>)

# You might wonder why we don't simply add the list of header files to the check_deps
# executable directly, and let cmake figure everything out on it's own.
Expand Down
12 changes: 0 additions & 12 deletions include/mqtt/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
#endif // !defined(MQTT_STD_VARIANT)


// Check whether to use standard executors only
#if defined(MQTT_NO_TS_EXECUTORS)

// Determine Boost Asio version
#include <boost/asio/version.hpp>

Expand All @@ -43,15 +40,6 @@
#error Boost Asio version 1.18.0 required for no TS-style executors
#endif // BOOST_ASIO_VERSION < 101800

#else // defined(MQTT_NO_TS_EXECUTORS)

// Force no TS executors if Boost Asio accepts these only
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
#define MQTT_NO_TS_EXECUTORS
#endif // defined(BOOST_ASIO_NO_TS_EXECUTORS)

#endif // defined(MQTT_NO_TS_EXECUTORS)

#define BOOST_UUID_FORCE_AUTO_LINK

#endif // MQTT_CONFIG_HPP
75 changes: 0 additions & 75 deletions include/mqtt/null_strand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,84 +17,9 @@ namespace MQTT_NS {

namespace as = boost::asio;

// Determines which strand to use
#if defined(MQTT_NO_TS_EXECUTORS)

// Using standard executor style null_strand / simple executor
using null_strand = as::io_context::executor_type;

#else // defined(MQTT_NO_TS_EXECUTORS)

namespace detail {

struct null_strand {
explicit null_strand(as::io_context& ioc) noexcept : ioc_(ioc) {}
template <typename Func, typename Allocator>
void post(Func&& f, Allocator) const {
as::post(
ioc_,
[f = std::forward<Func>(f)] () mutable {
std::move(f)();
}
);
}
template <typename Func, typename Allocator>
void defer(Func&& f, Allocator) const {
as::defer(
ioc_,
[f = std::forward<Func>(f)] () mutable {
std::move(f)();
}
);
}
template <typename Func, typename Allocator>
void dispatch(Func&& f, Allocator) const {
as::dispatch(
ioc_,
[f = std::forward<Func>(f)] () mutable {
std::move(f)();
}
);
}
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_; }
as::io_context const& context() const noexcept { return ioc_; }
private:
as::io_context& ioc_;
};

} // namespace detail

// Use networking TS style null_strand
using null_strand = detail::null_strand;

inline bool operator==(null_strand const& lhs, null_strand const& rhs) {
return std::addressof(lhs) == std::addressof(rhs);
}

inline bool operator!=(null_strand const& lhs, null_strand const& rhs) {
return !(lhs == rhs);
}

#endif // defined(MQTT_NO_TS_EXECUTORS)

} // namespace MQTT_NS


#if !defined(MQTT_NO_TS_EXECUTORS)

namespace boost {
namespace asio {

template<>
struct is_executor<MQTT_NS::null_strand> : std::true_type {
};

} // namespace asio
} // namespace boost

#endif // !defined(MQTT_NO_TS_EXECUTORS)

#endif // MQTT_NULL_STRAND_HPP
10 changes: 0 additions & 10 deletions include/mqtt/strand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,8 @@ namespace MQTT_NS {

namespace as = boost::asio;

// Determines which strand to use
#if defined(MQTT_NO_TS_EXECUTORS)

// Use standard executor style strand
using strand = as::strand<as::io_context::executor_type>;

#else // defined(MQTT_NO_TS_EXECUTORS)

// Use networking TS style strand
using strand = as::io_context::strand;

#endif // defined(MQTT_NO_TS_EXECUTORS)
}

#endif // MQTT_STRAND_HPP
12 changes: 1 addition & 11 deletions include/mqtt/tcp_endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ class tcp_endpoint : public socket {
template <typename... Args>
explicit tcp_endpoint(as::io_context& ioc, Args&&... args)
:tcp_(ioc, std::forward<Args>(args)...),
#if defined(MQTT_NO_TS_EXECUTORS)
strand_(ioc.get_executor())
#else
strand_(ioc)
#endif
{}

MQTT_ALWAYS_INLINE void async_read(
Expand Down Expand Up @@ -115,15 +111,9 @@ class tcp_endpoint : public socket {
tcp_.lowest_layer().close(ec);
}

#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
MQTT_ALWAYS_INLINE as::executor get_executor() override final {
return lowest_layer().get_executor();
}
#else // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
MQTT_ALWAYS_INLINE as::any_io_executor get_executor() override final {
return lowest_layer().get_executor();
return strand_;
}
#endif // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)

auto& socket() { return tcp_; }
auto const& socket() const { return tcp_; }
Expand Down
4 changes: 0 additions & 4 deletions include/mqtt/type_erased_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ class socket {
virtual void clean_shutdown_and_close(boost::system::error_code&) = 0;
virtual void async_clean_shutdown_and_close(std::function<void(error_code)>) = 0;
virtual void force_shutdown_and_close(boost::system::error_code&) = 0;
#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
virtual as::executor get_executor() = 0;
#else // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
virtual as::any_io_executor get_executor() = 0;
#endif // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
};

} // namespace MQTT_NS
Expand Down
12 changes: 1 addition & 11 deletions include/mqtt/ws_endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ class ws_endpoint : public socket {
template <typename... Args>
explicit ws_endpoint(as::io_context& ioc, Args&&... args)
:ws_(ioc, std::forward<Args>(args)...),
#if defined(MQTT_NO_TS_EXECUTORS)
strand_(ioc.get_executor())
#else
strand_(ioc)
#endif
{
ws_.binary(true);
ws_.set_option(
Expand Down Expand Up @@ -230,15 +226,9 @@ class ws_endpoint : public socket {
lowest_layer().close(ec);
}

#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
MQTT_ALWAYS_INLINE as::executor get_executor() override final {
return lowest_layer().get_executor();
}
#else // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
MQTT_ALWAYS_INLINE as::any_io_executor get_executor() override final {
return lowest_layer().get_executor();
return strand_;
}
#endif // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)

typename boost::beast::websocket::stream<Socket>::next_layer_type& next_layer() {
return ws_.next_layer();
Expand Down

0 comments on commit 0d9e718

Please sign in to comment.