Warning, file /include/boost/asio/detail/impl/strand_service.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_HPP
0012 #define BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/completion_handler.hpp>
0019 #include <boost/asio/detail/fenced_block.hpp>
0020 #include <boost/asio/detail/handler_alloc_helpers.hpp>
0021 #include <boost/asio/detail/memory.hpp>
0022
0023 #include <boost/asio/detail/push_options.hpp>
0024
0025 namespace boost {
0026 namespace asio {
0027 namespace detail {
0028
0029 inline strand_service::strand_impl::strand_impl()
0030 : operation(&strand_service::do_complete),
0031 locked_(false)
0032 {
0033 }
0034
0035 template <typename Handler>
0036 void strand_service::dispatch(strand_service::implementation_type& impl,
0037 Handler& handler)
0038 {
0039
0040 if (running_in_this_thread(impl))
0041 {
0042 fenced_block b(fenced_block::full);
0043 static_cast<Handler&&>(handler)();
0044 return;
0045 }
0046
0047
0048 typedef completion_handler<Handler, io_context::executor_type> op;
0049 typename op::ptr p = { boost::asio::detail::addressof(handler),
0050 op::ptr::allocate(handler), 0 };
0051 p.p = new (p.v) op(handler, io_context_.get_executor());
0052
0053 BOOST_ASIO_HANDLER_CREATION((this->context(),
0054 *p.p, "strand", impl, 0, "dispatch"));
0055
0056 operation* o = p.p;
0057 p.v = p.p = 0;
0058 do_dispatch(impl, o);
0059 }
0060
0061
0062 template <typename Handler>
0063 void strand_service::post(strand_service::implementation_type& impl,
0064 Handler& handler)
0065 {
0066 bool is_continuation =
0067 boost_asio_handler_cont_helpers::is_continuation(handler);
0068
0069
0070 typedef completion_handler<Handler, io_context::executor_type> op;
0071 typename op::ptr p = { boost::asio::detail::addressof(handler),
0072 op::ptr::allocate(handler), 0 };
0073 p.p = new (p.v) op(handler, io_context_.get_executor());
0074
0075 BOOST_ASIO_HANDLER_CREATION((this->context(),
0076 *p.p, "strand", impl, 0, "post"));
0077
0078 do_post(impl, p.p, is_continuation);
0079 p.v = p.p = 0;
0080 }
0081
0082 }
0083 }
0084 }
0085
0086 #include <boost/asio/detail/pop_options.hpp>
0087
0088 #endif