]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/impl/execution_context.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / asio / impl / execution_context.hpp
CommitLineData
b32b8144
FG
1//
2// impl/execution_context.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
11fdf7f2 5// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
b32b8144
FG
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#ifndef BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP
12#define BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/handler_type_requirements.hpp>
19#include <boost/asio/detail/scoped_ptr.hpp>
20#include <boost/asio/detail/service_registry.hpp>
21
22#include <boost/asio/detail/push_options.hpp>
23
24namespace boost {
25namespace asio {
26
27template <typename Service>
28inline Service& use_service(execution_context& e)
29{
30 // Check that Service meets the necessary type requirements.
31 (void)static_cast<execution_context::service*>(static_cast<Service*>(0));
32
33 return e.service_registry_->template use_service<Service>();
34}
35
36#if !defined(GENERATING_DOCUMENTATION)
37# if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
38
39template <typename Service, typename... Args>
40Service& make_service(execution_context& e, BOOST_ASIO_MOVE_ARG(Args)... args)
41{
42 detail::scoped_ptr<Service> svc(
43 new Service(e, BOOST_ASIO_MOVE_CAST(Args)(args)...));
44 e.service_registry_->template add_service<Service>(svc.get());
45 Service& result = *svc;
46 svc.release();
47 return result;
48}
49
50# else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
51
52template <typename Service>
53Service& make_service(execution_context& e)
54{
55 detail::scoped_ptr<Service> svc(new Service(e));
56 e.service_registry_->template add_service<Service>(svc.get());
57 Service& result = *svc;
58 svc.release();
59 return result;
60}
61
62#define BOOST_ASIO_PRIVATE_MAKE_SERVICE_DEF(n) \
63 template <typename Service, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
64 Service& make_service(execution_context& e, \
65 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
66 { \
67 detail::scoped_ptr<Service> svc( \
68 new Service(e, BOOST_ASIO_VARIADIC_MOVE_ARGS(n))); \
69 e.service_registry_->template add_service<Service>(svc.get()); \
70 Service& result = *svc; \
71 svc.release(); \
72 return result; \
73 } \
74 /**/
75 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_MAKE_SERVICE_DEF)
76#undef BOOST_ASIO_PRIVATE_MAKE_SERVICE_DEF
77
78# endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
79#endif // !defined(GENERATING_DOCUMENTATION)
80
81template <typename Service>
82inline void add_service(execution_context& e, Service* svc)
83{
84 // Check that Service meets the necessary type requirements.
85 (void)static_cast<execution_context::service*>(static_cast<Service*>(0));
86
87 e.service_registry_->template add_service<Service>(svc);
88}
89
90template <typename Service>
91inline bool has_service(execution_context& e)
92{
93 // Check that Service meets the necessary type requirements.
94 (void)static_cast<execution_context::service*>(static_cast<Service*>(0));
95
96 return e.service_registry_->template has_service<Service>();
97}
98
99inline execution_context& execution_context::service::context()
100{
101 return owner_;
102}
103
104} // namespace asio
105} // namespace boost
106
107#include <boost/asio/detail/pop_options.hpp>
108
109#endif // BOOST_ASIO_IMPL_EXECUTION_CONTEXT_HPP