Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:10

0001 //
0002 // packaged_task.hpp
0003 // ~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 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_PACKAGED_TASK_HPP
0012 #define BOOST_ASIO_PACKAGED_TASK_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/config.hpp>
0019 #include <boost/asio/detail/future.hpp>
0020 
0021 #if defined(BOOST_ASIO_HAS_STD_FUTURE_CLASS) \
0022   || defined(GENERATING_DOCUMENTATION)
0023 
0024 #include <boost/asio/async_result.hpp>
0025 #include <boost/asio/detail/type_traits.hpp>
0026 
0027 #include <boost/asio/detail/push_options.hpp>
0028 
0029 namespace boost {
0030 namespace asio {
0031 
0032 /// Partial specialisation of @c async_result for @c std::packaged_task.
0033 template <typename Result, typename... Args, typename Signature>
0034 class async_result<std::packaged_task<Result(Args...)>, Signature>
0035 {
0036 public:
0037   /// The packaged task is the concrete completion handler type.
0038   typedef std::packaged_task<Result(Args...)> completion_handler_type;
0039 
0040   /// The return type of the initiating function is the future obtained from
0041   /// the packaged task.
0042   typedef std::future<Result> return_type;
0043 
0044   /// The constructor extracts the future from the packaged task.
0045   explicit async_result(completion_handler_type& h)
0046     : future_(h.get_future())
0047   {
0048   }
0049 
0050   /// Returns the packaged task's future.
0051   return_type get()
0052   {
0053     return std::move(future_);
0054   }
0055 
0056 private:
0057   return_type future_;
0058 };
0059 
0060 } // namespace asio
0061 } // namespace boost
0062 
0063 #include <boost/asio/detail/pop_options.hpp>
0064 
0065 #endif // defined(BOOST_ASIO_HAS_STD_FUTURE_CLASS)
0066        //   || defined(GENERATING_DOCUMENTATION)
0067 
0068 #endif // BOOST_ASIO_PACKAGED_TASK_HPP