diff options
Diffstat (limited to '3rdparty/asio/include/asio/detail/impl/strand_executor_service.hpp')
-rw-r--r-- | 3rdparty/asio/include/asio/detail/impl/strand_executor_service.hpp | 112 |
1 files changed, 52 insertions, 60 deletions
diff --git a/3rdparty/asio/include/asio/detail/impl/strand_executor_service.hpp b/3rdparty/asio/include/asio/detail/impl/strand_executor_service.hpp index b66b6747f01..3ffb398dcf6 100644 --- a/3rdparty/asio/include/asio/detail/impl/strand_executor_service.hpp +++ b/3rdparty/asio/include/asio/detail/impl/strand_executor_service.hpp @@ -2,7 +2,7 @@ // detail/impl/strand_executor_service.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,6 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/fenced_block.hpp" -#include "asio/detail/handler_invoke_helpers.hpp" #include "asio/detail/recycling_allocator.hpp" #include "asio/executor_work_guard.hpp" #include "asio/defer.hpp" @@ -34,8 +33,8 @@ class strand_executor_service::allocator_binder public: typedef Allocator allocator_type; - allocator_binder(ASIO_MOVE_ARG(F) f, const Allocator& a) - : f_(ASIO_MOVE_CAST(F)(f)), + allocator_binder(F&& f, const Allocator& a) + : f_(static_cast<F&&>(f)), allocator_(a) { } @@ -46,15 +45,13 @@ public: { } -#if defined(ASIO_HAS_MOVE) allocator_binder(allocator_binder&& other) - : f_(ASIO_MOVE_CAST(F)(other.f_)), - allocator_(ASIO_MOVE_CAST(allocator_type)(other.allocator_)) + : f_(static_cast<F&&>(other.f_)), + allocator_(static_cast<allocator_type&&>(other.allocator_)) { } -#endif // defined(ASIO_HAS_MOVE) - allocator_type get_allocator() const ASIO_NOEXCEPT + allocator_type get_allocator() const noexcept { return allocator_; } @@ -71,9 +68,9 @@ private: template <typename Executor> class strand_executor_service::invoker<Executor, - typename enable_if< + enable_if_t< execution::is_executor<Executor>::value - >::type> + >> { public: invoker(const implementation_type& impl, Executor& ex) @@ -88,13 +85,11 @@ public: { } -#if defined(ASIO_HAS_MOVE) invoker(invoker&& other) - : impl_(ASIO_MOVE_CAST(implementation_type)(other.impl_)), - executor_(ASIO_MOVE_CAST(executor_type)(other.executor_)) + : impl_(static_cast<implementation_type&&>(other.impl_)), + executor_(static_cast<executor_type&&>(other.executor_)) { } -#endif // defined(ASIO_HAS_MOVE) struct on_invoker_exit { @@ -106,13 +101,12 @@ public: { recycling_allocator<void> allocator; executor_type ex = this_->executor_; - execution::execute( - asio::prefer( - asio::require( - ASIO_MOVE_CAST(executor_type)(ex), - execution::blocking.never), - execution::allocator(allocator)), - ASIO_MOVE_CAST(invoker)(*this_)); + asio::prefer( + asio::require( + static_cast<executor_type&&>(ex), + execution::blocking.never), + execution::allocator(allocator) + ).execute(static_cast<invoker&&>(*this_)); } } }; @@ -127,12 +121,12 @@ public: } private: - typedef typename decay< - typename prefer_result< + typedef decay_t< + prefer_result_t< Executor, execution::outstanding_work_t::tracked_t - >::type - >::type executor_type; + > + > executor_type; implementation_type impl_; executor_type executor_; @@ -142,9 +136,9 @@ private: template <typename Executor> class strand_executor_service::invoker<Executor, - typename enable_if< + enable_if_t< !execution::is_executor<Executor>::value - >::type> + >> { public: invoker(const implementation_type& impl, Executor& ex) @@ -159,13 +153,11 @@ public: { } -#if defined(ASIO_HAS_MOVE) invoker(invoker&& other) - : impl_(ASIO_MOVE_CAST(implementation_type)(other.impl_)), - work_(ASIO_MOVE_CAST(executor_work_guard<Executor>)(other.work_)) + : impl_(static_cast<implementation_type&&>(other.impl_)), + work_(static_cast<executor_work_guard<Executor>&&>(other.work_)) { } -#endif // defined(ASIO_HAS_MOVE) struct on_invoker_exit { @@ -177,7 +169,7 @@ public: { Executor ex(this_->work_.get_executor()); recycling_allocator<void> allocator; - ex.post(ASIO_MOVE_CAST(invoker)(*this_), allocator); + ex.post(static_cast<invoker&&>(*this_), allocator); } } }; @@ -200,33 +192,33 @@ private: template <typename Executor, typename Function> inline void strand_executor_service::execute(const implementation_type& impl, - Executor& ex, ASIO_MOVE_ARG(Function) function, - typename enable_if< - can_query<Executor, execution::allocator_t<void> >::value - >::type*) + Executor& ex, Function&& function, + enable_if_t< + can_query<Executor, execution::allocator_t<void>>::value + >*) { return strand_executor_service::do_execute(impl, ex, - ASIO_MOVE_CAST(Function)(function), + static_cast<Function&&>(function), asio::query(ex, execution::allocator)); } template <typename Executor, typename Function> inline void strand_executor_service::execute(const implementation_type& impl, - Executor& ex, ASIO_MOVE_ARG(Function) function, - typename enable_if< - !can_query<Executor, execution::allocator_t<void> >::value - >::type*) + Executor& ex, Function&& function, + enable_if_t< + !can_query<Executor, execution::allocator_t<void>>::value + >*) { return strand_executor_service::do_execute(impl, ex, - ASIO_MOVE_CAST(Function)(function), + static_cast<Function&&>(function), std::allocator<void>()); } template <typename Executor, typename Function, typename Allocator> void strand_executor_service::do_execute(const implementation_type& impl, - Executor& ex, ASIO_MOVE_ARG(Function) function, const Allocator& a) + Executor& ex, Function&& function, const Allocator& a) { - typedef typename decay<Function>::type function_type; + typedef decay_t<Function> function_type; // If the executor is not never-blocking, and we are already in the strand, // then the function can run immediately. @@ -234,17 +226,17 @@ void strand_executor_service::do_execute(const implementation_type& impl, && running_in_this_thread(impl)) { // Make a local, non-const copy of the function. - function_type tmp(ASIO_MOVE_CAST(Function)(function)); + function_type tmp(static_cast<Function&&>(function)); fenced_block b(fenced_block::full); - asio_handler_invoke_helpers::invoke(tmp, tmp); + static_cast<function_type&&>(tmp)(); return; } // Allocate and construct an operation to wrap the function. typedef executor_op<function_type, Allocator> op; typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 }; - p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(function), a); + p.p = new (p.v) op(static_cast<Function&&>(function), a); ASIO_HANDLER_CREATION((impl->service_->context(), *p.p, "strand_executor", impl.get(), 0, "execute")); @@ -254,31 +246,31 @@ void strand_executor_service::do_execute(const implementation_type& impl, p.v = p.p = 0; if (first) { - execution::execute(ex, invoker<Executor>(impl, ex)); + ex.execute(invoker<Executor>(impl, ex)); } } template <typename Executor, typename Function, typename Allocator> void strand_executor_service::dispatch(const implementation_type& impl, - Executor& ex, ASIO_MOVE_ARG(Function) function, const Allocator& a) + Executor& ex, Function&& function, const Allocator& a) { - typedef typename decay<Function>::type function_type; + typedef decay_t<Function> function_type; // If we are already in the strand then the function can run immediately. if (running_in_this_thread(impl)) { // Make a local, non-const copy of the function. - function_type tmp(ASIO_MOVE_CAST(Function)(function)); + function_type tmp(static_cast<Function&&>(function)); fenced_block b(fenced_block::full); - asio_handler_invoke_helpers::invoke(tmp, tmp); + static_cast<function_type&&>(tmp)(); return; } // Allocate and construct an operation to wrap the function. typedef executor_op<function_type, Allocator> op; typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 }; - p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(function), a); + p.p = new (p.v) op(static_cast<Function&&>(function), a); ASIO_HANDLER_CREATION((impl->service_->context(), *p.p, "strand_executor", impl.get(), 0, "dispatch")); @@ -297,14 +289,14 @@ void strand_executor_service::dispatch(const implementation_type& impl, // Request invocation of the given function and return immediately. template <typename Executor, typename Function, typename Allocator> void strand_executor_service::post(const implementation_type& impl, - Executor& ex, ASIO_MOVE_ARG(Function) function, const Allocator& a) + Executor& ex, Function&& function, const Allocator& a) { - typedef typename decay<Function>::type function_type; + typedef decay_t<Function> function_type; // Allocate and construct an operation to wrap the function. typedef executor_op<function_type, Allocator> op; typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 }; - p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(function), a); + p.p = new (p.v) op(static_cast<Function&&>(function), a); ASIO_HANDLER_CREATION((impl->service_->context(), *p.p, "strand_executor", impl.get(), 0, "post")); @@ -323,14 +315,14 @@ void strand_executor_service::post(const implementation_type& impl, // Request invocation of the given function and return immediately. template <typename Executor, typename Function, typename Allocator> void strand_executor_service::defer(const implementation_type& impl, - Executor& ex, ASIO_MOVE_ARG(Function) function, const Allocator& a) + Executor& ex, Function&& function, const Allocator& a) { - typedef typename decay<Function>::type function_type; + typedef decay_t<Function> function_type; // Allocate and construct an operation to wrap the function. typedef executor_op<function_type, Allocator> op; typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 }; - p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(function), a); + p.p = new (p.v) op(static_cast<Function&&>(function), a); ASIO_HANDLER_CREATION((impl->service_->context(), *p.p, "strand_executor", impl.get(), 0, "defer")); |