Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

async_result.hpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // async_result.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  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. #ifndef ASIO_ASYNC_RESULT_HPP
  11. #define ASIO_ASYNC_RESULT_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/detail/type_traits.hpp"
  17. #include "asio/handler_type.hpp"
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. /// An interface for customising the behaviour of an initiating function.
  21. /**
  22. * This template may be specialised for user-defined handler types.
  23. */
  24. template <typename Handler>
  25. class async_result
  26. {
  27. public:
  28. /// The return type of the initiating function.
  29. typedef void type;
  30. /// Construct an async result from a given handler.
  31. /**
  32. * When using a specalised async_result, the constructor has an opportunity
  33. * to initialise some state associated with the handler, which is then
  34. * returned from the initiating function.
  35. */
  36. explicit async_result(Handler&)
  37. {
  38. }
  39. /// Obtain the value to be returned from the initiating function.
  40. type get()
  41. {
  42. }
  43. };
  44. /// Helper template to deduce the real type of a handler, capture a local copy
  45. /// of the handler, and then create an async_result for the handler.
  46. template <typename Handler, typename Signature>
  47. struct async_completion
  48. {
  49. /// The real handler type to be used for the asynchronous operation.
  50. typedef typename asio::handler_type<
  51. Handler, Signature>::type handler_type;
  52. /// Constructor.
  53. /**
  54. * The constructor creates the concrete handler and makes the link between
  55. * the handler and the asynchronous result.
  56. */
  57. #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  58. explicit async_completion(
  59. Handler& orig_handler)
  60. : handler(static_cast<typename conditional<
  61. is_same<Handler, handler_type>::value,
  62. handler_type&, Handler&&>::type>(orig_handler)),
  63. result(handler)
  64. {
  65. }
  66. #else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  67. explicit async_completion(const Handler& orig_handler)
  68. : handler(orig_handler),
  69. result(handler)
  70. {
  71. }
  72. #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  73. /// A copy of, or reference to, a real handler object.
  74. #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  75. typename conditional<
  76. is_same<Handler, handler_type>::value,
  77. handler_type&, handler_type>::type handler;
  78. #else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  79. typename asio::handler_type<Handler, Signature>::type handler;
  80. #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  81. /// The result of the asynchronous operation's initiating function.
  82. async_result<typename asio::handler_type<
  83. Handler, Signature>::type> result;
  84. };
  85. namespace detail {
  86. template <typename Handler, typename Signature>
  87. struct async_result_type_helper
  88. {
  89. typedef typename async_result<
  90. typename handler_type<Handler, Signature>::type
  91. >::type type;
  92. };
  93. } // namespace detail
  94. } // namespace asio
  95. #include "asio/detail/pop_options.hpp"
  96. #if defined(GENERATING_DOCUMENTATION)
  97. # define ASIO_INITFN_RESULT_TYPE(h, sig) \
  98. void_or_deduced
  99. #elif defined(_MSC_VER) && (_MSC_VER < 1500)
  100. # define ASIO_INITFN_RESULT_TYPE(h, sig) \
  101. typename ::asio::detail::async_result_type_helper<h, sig>::type
  102. #else
  103. # define ASIO_INITFN_RESULT_TYPE(h, sig) \
  104. typename ::asio::async_result< \
  105. typename ::asio::handler_type<h, sig>::type>::type
  106. #endif
  107. #endif // ASIO_ASYNC_RESULT_HPP