From de1e63c59717fc79e15fce597b1fdfb451e4d480 Mon Sep 17 00:00:00 2001 From: Richard Hodges Date: Sat, 4 Jul 2020 07:33:22 +0200 Subject: [PATCH] Fix style errors --- example/http/client/crawl/http_crawl.cpp | 7 +-- include/boost/beast/core/async_base.hpp | 3 +- .../core/detail/bind_default_executor.hpp | 13 ----- test/beast/core/_detail_get_io_context.cpp | 7 --- test/beast/core/basic_stream.cpp | 36 ------------- test/beast/core/bind_handler.cpp | 50 +++++++++---------- test/beast/core/test_handler.hpp | 7 +-- test/doc/core_1_refresher.cpp | 2 +- test/doc/core_snippets.cpp | 4 +- test/doc/http_snippets.cpp | 4 +- test/doc/snippets.ipp | 4 +- 11 files changed, 39 insertions(+), 98 deletions(-) diff --git a/example/http/client/crawl/http_crawl.cpp b/example/http/client/crawl/http_crawl.cpp index 57ecfe9e..a6fc4eba 100644 --- a/example/http/client/crawl/http_crawl.cpp +++ b/example/http/client/crawl/http_crawl.cpp @@ -355,11 +355,12 @@ int main(int argc, char* argv[]) // The io_context is required for all I/O net::io_context ioc; - // The work keeps io_context::run from returning - auto work = net::any_io_executor( + // Building a tracked executor ensures that the underlying context's + // run() function will not return until the tracked executor is destroyed + net::any_io_executor work = net::prefer( ioc.get_executor(), - net::execution::outstanding_work.tracked)); + net::execution::outstanding_work.tracked); // The report holds the aggregated statistics crawl_report report{ioc}; diff --git a/include/boost/beast/core/async_base.hpp b/include/boost/beast/core/async_base.hpp index baa9c992..1aa31267 100644 --- a/include/boost/beast/core/async_base.hpp +++ b/include/boost/beast/core/async_base.hpp @@ -304,7 +304,8 @@ public: executor_type get_executor() const noexcept { - return net::get_associated_executor(h_, wg1_.get_executor()); + return net::get_associated_executor( + h_, wg1_.get_executor()); } /// Returns the handler associated with this object diff --git a/include/boost/beast/core/detail/bind_default_executor.hpp b/include/boost/beast/core/detail/bind_default_executor.hpp index 095d8bf3..c34a9027 100644 --- a/include/boost/beast/core/detail/bind_default_executor.hpp +++ b/include/boost/beast/core/detail/bind_default_executor.hpp @@ -67,19 +67,6 @@ public: h_, this->get()); } - // The invocation hook is no longer defined because it customises behaviour - // without forwarding to a user's hook. - -#if 0 - template - void - asio_handler_invoke(Function&& f, - bind_default_executor_wrapper* p) - { - net::dispatch(p->get_executor(), std::move(f)); - } -#endif - // The allocation hooks are still defined because they trivially forward to // user hooks. Forward here ensures that the user will get a compile error // if they build their code with BOOST_ASIO_NO_DEPRECATED. diff --git a/test/beast/core/_detail_get_io_context.cpp b/test/beast/core/_detail_get_io_context.cpp index 95aa54d8..a648caef 100644 --- a/test/beast/core/_detail_get_io_context.cpp +++ b/test/beast/core/_detail_get_io_context.cpp @@ -33,13 +33,6 @@ public: BEAST_EXPECT(get_io_context(ioc.get_executor()) == &ioc); BEAST_EXPECT(get_io_context(net::make_strand(ioc)) == &ioc); BEAST_EXPECT(get_io_context(net::any_io_executor(ioc.get_executor())) == &ioc); -#if 0 - // VFALCO FIXME - BEAST_EXPECT( - get_io_context( - net::strand( - net::any_io_executor(ioc.get_executor()))) == &ioc); -#endif } void diff --git a/test/beast/core/basic_stream.cpp b/test/beast/core/basic_stream.cpp index d835e78a..ab71bff5 100644 --- a/test/beast/core/basic_stream.cpp +++ b/test/beast/core/basic_stream.cpp @@ -40,18 +40,6 @@ namespace boost { namespace beast { -#if 0 -template class basic_stream< - net::ip::tcp, - net::any_io_executor, - unlimited_rate_policy>; - -template class basic_stream< - net::ip::tcp, - net::any_io_executor, - simple_rate_policy>; -#endif - namespace { template @@ -376,20 +364,10 @@ public: basic_stream s1(ex); basic_stream s2(ex, tcp::v4()); basic_stream s3(std::move(s1)); - #if 0 - s2.socket() = net::basic_stream_socket< - tcp, strand>(ioc); - #endif BEAST_EXPECT(s1.get_executor() == ex); BEAST_EXPECT(s2.get_executor() == ex); BEAST_EXPECT(s3.get_executor() == ex); -#if 0 - BEAST_EXPECT((! static_cast< - basic_stream const&>( - s2).socket().is_open())); -#endif - test_sync_stream< basic_stream< tcp, strand>>(); @@ -399,20 +377,6 @@ public: tcp, strand>>(); } - // construction from existing socket - -#if 0 - { - tcp::socket sock(ioc); - basic_stream stream(std::move(sock)); - } - - { - tcp::socket sock(ioc); - basic_stream stream(std::move(sock)); - } -#endif - // layers { diff --git a/test/beast/core/bind_handler.cpp b/test/beast/core/bind_handler.cpp index 7348c3d9..4c0b071b 100644 --- a/test/beast/core/bind_handler.cpp +++ b/test/beast/core/bind_handler.cpp @@ -127,29 +127,39 @@ public: #if defined(BOOST_ASIO_NO_TS_EXECUTORS) - net::execution_context& query(net::execution::context_t c) const noexcept + net::execution_context& + query( + net::execution::context_t c) const noexcept { return net::query(ex_, c); } - net::execution::blocking_t query(net::execution::blocking_t) const noexcept + net::execution::blocking_t + query( + net::execution::blocking_t) const noexcept { return blocking_; } - net::execution::outstanding_work_t query(net::execution::outstanding_work_t w) const noexcept + net::execution::outstanding_work_t + query( + net::execution::outstanding_work_t w) const noexcept { return net::query(ex_, w); } - test_executor require(net::execution::blocking_t::possibly_t b) const + test_executor + require( + net::execution::blocking_t::possibly_t b) const { test_executor new_ex(*this); new_ex.blocking_ = b; return new_ex; } - test_executor require(net::execution::blocking_t::never_t b) const + test_executor + require( + net::execution::blocking_t::never_t b) const { test_executor new_ex(*this); new_ex.blocking_ = b; @@ -193,18 +203,21 @@ public: return ex_.context(); } - void on_work_started() const noexcept + void + on_work_started() const noexcept { ex_.on_work_started(); } - void on_work_finished() const noexcept + void + on_work_finished() const noexcept { ex_.on_work_finished(); } template - void dispatch(F&& f, Alloc const& a) + void + dispatch(F&& f, Alloc const& a) { s_.on_invoke(); net::execution::execute( @@ -217,7 +230,8 @@ public: } template - void post(F&& f, Alloc const& a) + void + post(F&& f, Alloc const& a) { // shouldn't be called since the enclosing // networking wrapper only uses dispatch @@ -225,7 +239,8 @@ public: } template - void defer(F&& f, Alloc const& a) + void + defer(F&& f, Alloc const& a) { // shouldn't be called since the enclosing // networking wrapper only uses dispatch @@ -235,21 +250,6 @@ public: }; #if defined(BOOST_ASIO_NO_TS_EXECUTORS) - using F = net::execution::invocable_archetype; - using T = test_executor; - - BOOST_STATIC_ASSERT( - conditional::type&()>::type - >::type::value); - - BOOST_STATIC_ASSERT(std::is_constructible::type, F>::value); - BOOST_STATIC_ASSERT(std::is_move_constructible::type>::value); - BOOST_STATIC_ASSERT(boost::asio::execution::can_execute::value); - BOOST_STATIC_ASSERT(std::is_nothrow_copy_constructible::value); - BOOST_STATIC_ASSERT(std::is_nothrow_destructible::value); - BOOST_STATIC_ASSERT(boost::asio::traits::equality_comparable::is_valid); - BOOST_STATIC_ASSERT(boost::asio::traits::equality_comparable::is_noexcept); BOOST_STATIC_ASSERT(net::execution::is_executor::value); #else BOOST_STATIC_ASSERT(net::is_executor::value); diff --git a/test/beast/core/test_handler.hpp b/test/beast/core/test_handler.hpp index a6d92abe..ac6b946d 100644 --- a/test/beast/core/test_handler.hpp +++ b/test/beast/core/test_handler.hpp @@ -98,12 +98,7 @@ public: }; #if defined(BOOST_ASIO_NO_TS_EXECUTORS) -static_assert(net::execution::can_execute::value, ""); -static_assert(std::is_nothrow_copy_constructible::value, ""); -static_assert(std::is_nothrow_destructible::value, ""); -static_assert(net::traits::equality_comparable::is_valid, ""); -static_assert(net::traits::equality_comparable::is_noexcept, ""); -static_assert(net::execution::is_executor::value, ""); +BOOST_STATIC_ASSERT(net::execution::is_executor::value); #endif // A move-only handler diff --git a/test/doc/core_1_refresher.cpp b/test/doc/core_1_refresher.cpp index d0e18196..02f7610e 100644 --- a/test/doc/core_1_refresher.cpp +++ b/test/doc/core_1_refresher.cpp @@ -288,7 +288,7 @@ struct associated_allocator template struct associated_executor { - using type = boost::asio::any_io_executor; + using type = any_io_executor; static type diff --git a/test/doc/core_snippets.cpp b/test/doc/core_snippets.cpp index 32dbcf26..eb52e70f 100644 --- a/test/doc/core_snippets.cpp +++ b/test/doc/core_snippets.cpp @@ -38,9 +38,9 @@ namespace ssl = boost::asio::ssl; using tcp = net::ip::tcp; net::io_context ioc; -auto work = net::any_io_executor( +net::any_io_executor work = net::prefer(ioc.get_executor(), - net::execution::outstanding_work.tracked)); + net::execution::outstanding_work.tracked); std::thread t{[&](){ ioc.run(); }}; error_code ec; diff --git a/test/doc/http_snippets.cpp b/test/doc/http_snippets.cpp index c386c8f2..7f33626a 100644 --- a/test/doc/http_snippets.cpp +++ b/test/doc/http_snippets.cpp @@ -37,10 +37,10 @@ net::const_buffer get_next_chunk_body() void fxx() { net::io_context ioc; - auto work = net::any_io_executor( + net::any_io_executor work = net::prefer( ioc.get_executor(), - net::execution::outstanding_work.tracked)); + net::execution::outstanding_work.tracked); std::thread t{[&](){ ioc.run(); }}; net::ip::tcp::socket sock{ioc}; diff --git a/test/doc/snippets.ipp b/test/doc/snippets.ipp index 67914271..b6d2b74f 100644 --- a/test/doc/snippets.ipp +++ b/test/doc/snippets.ipp @@ -17,10 +17,10 @@ using tcp = net::ip::tcp; error_code ec; net::io_context ioc; -auto work = net::any_io_executor( +net::any_io_executor work = net::prefer( ioc.get_executor(), - net::execution::outstanding_work.tracked)); + net::execution::outstanding_work.tracked); std::thread t{[&](){ ioc.run(); }}; tcp::socket sock(ioc);