Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:03:03

0001 //
0002 // experimental/impl/use_promise.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2021-2023 Klemens D. Morgenstern
0006 //                         (klemens dot morgenstern at gmx dot net)
0007 //
0008 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 
0012 #ifndef BOOST_ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP
0013 #define BOOST_ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP
0014 
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016 # pragma once
0017 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0018 
0019 #include <boost/asio/detail/config.hpp>
0020 #include <memory>
0021 #include <boost/asio/async_result.hpp>
0022 
0023 #include <boost/asio/detail/push_options.hpp>
0024 
0025 namespace boost {
0026 namespace asio {
0027 namespace experimental {
0028 
0029 template <typename Allocator>
0030 struct use_promise_t;
0031 
0032 namespace detail {
0033 
0034 template<typename Signature, typename Executor, typename Allocator>
0035 struct promise_handler;
0036 
0037 } // namespace detail
0038 } // namespace experimental
0039 
0040 #if !defined(GENERATING_DOCUMENTATION)
0041 
0042 template <typename Allocator, typename R, typename... Args>
0043 struct async_result<experimental::use_promise_t<Allocator>, R(Args...)>
0044 {
0045   template <typename Initiation, typename... InitArgs>
0046   static auto initiate(Initiation initiation,
0047       experimental::use_promise_t<Allocator> up, InitArgs... args)
0048     -> experimental::promise<void(decay_t<Args>...),
0049       boost::asio::associated_executor_t<Initiation>, Allocator>
0050   {
0051     using handler_type = experimental::detail::promise_handler<
0052       void(decay_t<Args>...),
0053       boost::asio::associated_executor_t<Initiation>, Allocator>;
0054 
0055     handler_type ht{up.get_allocator(), get_associated_executor(initiation)};
0056     std::move(initiation)(ht, std::move(args)...);
0057     return ht.make_promise();
0058   }
0059 };
0060 
0061 #endif // !defined(GENERATING_DOCUMENTATION)
0062 
0063 } // namespace asio
0064 } // namespace boost
0065 
0066 #include <boost/asio/detail/pop_options.hpp>
0067 
0068 #endif // BOOST_ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP