File indexing completed on 2025-01-18 09:28:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_EXECUTOR_OP_HPP
0012 #define BOOST_ASIO_DETAIL_EXECUTOR_OP_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/fenced_block.hpp>
0020 #include <boost/asio/detail/handler_alloc_helpers.hpp>
0021 #include <boost/asio/detail/scheduler_operation.hpp>
0022
0023 #include <boost/asio/detail/push_options.hpp>
0024
0025 namespace boost {
0026 namespace asio {
0027 namespace detail {
0028
0029 template <typename Handler, typename Alloc,
0030 typename Operation = scheduler_operation>
0031 class executor_op : public Operation
0032 {
0033 public:
0034 BOOST_ASIO_DEFINE_HANDLER_ALLOCATOR_PTR(executor_op);
0035
0036 template <typename H>
0037 executor_op(H&& h, const Alloc& allocator)
0038 : Operation(&executor_op::do_complete),
0039 handler_(static_cast<H&&>(h)),
0040 allocator_(allocator)
0041 {
0042 }
0043
0044 static void do_complete(void* owner, Operation* base,
0045 const boost::system::error_code& ,
0046 std::size_t )
0047 {
0048
0049 BOOST_ASIO_ASSUME(base != 0);
0050 executor_op* o(static_cast<executor_op*>(base));
0051 Alloc allocator(o->allocator_);
0052 ptr p = { detail::addressof(allocator), o, o };
0053
0054 BOOST_ASIO_HANDLER_COMPLETION((*o));
0055
0056
0057
0058
0059
0060
0061
0062 Handler handler(static_cast<Handler&&>(o->handler_));
0063 p.reset();
0064
0065
0066 if (owner)
0067 {
0068 fenced_block b(fenced_block::half);
0069 BOOST_ASIO_HANDLER_INVOCATION_BEGIN(());
0070 static_cast<Handler&&>(handler)();
0071 BOOST_ASIO_HANDLER_INVOCATION_END;
0072 }
0073 }
0074
0075 private:
0076 Handler handler_;
0077 Alloc allocator_;
0078 };
0079
0080 }
0081 }
0082 }
0083
0084 #include <boost/asio/detail/pop_options.hpp>
0085
0086 #endif