Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/asio/impl/execution_context.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // impl/execution_context.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP
0012 #define BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/handler_type_requirements.hpp>
0019 #include <boost/asio/detail/scoped_ptr.hpp>
0020 #include <boost/asio/detail/service_registry.hpp>
0021 
0022 #include <boost/asio/detail/push_options.hpp>
0023 
0024 namespace boost {
0025 namespace asio {
0026 
0027 #if !defined(GENERATING_DOCUMENTATION)
0028 
0029 template <typename Service>
0030 inline Service& use_service(execution_context& e)
0031 {
0032   // Check that Service meets the necessary type requirements.
0033   (void)static_cast<execution_context::service*>(static_cast<Service*>(0));
0034 
0035   return e.service_registry_->template use_service<Service>();
0036 }
0037 
0038 template <typename Service, typename... Args>
0039 Service& make_service(execution_context& e, Args&&... args)
0040 {
0041   detail::scoped_ptr<Service> svc(
0042       new Service(e, static_cast<Args&&>(args)...));
0043   e.service_registry_->template add_service<Service>(svc.get());
0044   Service& result = *svc;
0045   svc.release();
0046   return result;
0047 }
0048 
0049 template <typename Service>
0050 inline void add_service(execution_context& e, Service* svc)
0051 {
0052   // Check that Service meets the necessary type requirements.
0053   (void)static_cast<execution_context::service*>(static_cast<Service*>(0));
0054 
0055   e.service_registry_->template add_service<Service>(svc);
0056 }
0057 
0058 template <typename Service>
0059 inline bool has_service(execution_context& e)
0060 {
0061   // Check that Service meets the necessary type requirements.
0062   (void)static_cast<execution_context::service*>(static_cast<Service*>(0));
0063 
0064   return e.service_registry_->template has_service<Service>();
0065 }
0066 
0067 #endif // !defined(GENERATING_DOCUMENTATION)
0068 
0069 inline execution_context& execution_context::service::context()
0070 {
0071   return owner_;
0072 }
0073 
0074 } // namespace asio
0075 } // namespace boost
0076 
0077 #include <boost/asio/detail/pop_options.hpp>
0078 
0079 #endif // BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP