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.

131 lines
3.0KB

  1. //
  2. // impl/detached.hpp
  3. // ~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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_IMPL_DETACHED_HPP
  11. #define ASIO_IMPL_DETACHED_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/async_result.hpp"
  17. #include "asio/detail/variadic_templates.hpp"
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. namespace detail {
  21. // Class to adapt a detached_t as a completion handler.
  22. class detached_handler
  23. {
  24. public:
  25. typedef void result_type;
  26. detached_handler(detached_t)
  27. {
  28. }
  29. #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
  30. template <typename... Args>
  31. void operator()(Args...)
  32. {
  33. }
  34. #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
  35. void operator()()
  36. {
  37. }
  38. #define ASIO_PRIVATE_DETACHED_DEF(n) \
  39. template <ASIO_VARIADIC_TPARAMS(n)> \
  40. void operator()(ASIO_VARIADIC_TARGS(n)) \
  41. { \
  42. } \
  43. /**/
  44. ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_DETACHED_DEF)
  45. #undef ASIO_PRIVATE_DETACHED_DEF
  46. #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
  47. };
  48. } // namespace detail
  49. #if !defined(GENERATING_DOCUMENTATION)
  50. template <typename Signature>
  51. struct async_result<detached_t, Signature>
  52. {
  53. typedef asio::detail::detached_handler completion_handler_type;
  54. typedef void return_type;
  55. explicit async_result(completion_handler_type&)
  56. {
  57. }
  58. void get()
  59. {
  60. }
  61. #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
  62. template <typename Initiation, typename RawCompletionToken, typename... Args>
  63. static return_type initiate(
  64. ASIO_MOVE_ARG(Initiation) initiation,
  65. ASIO_MOVE_ARG(RawCompletionToken),
  66. ASIO_MOVE_ARG(Args)... args)
  67. {
  68. ASIO_MOVE_CAST(Initiation)(initiation)(
  69. detail::detached_handler(detached_t()),
  70. ASIO_MOVE_CAST(Args)(args)...);
  71. }
  72. #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
  73. template <typename Initiation, typename RawCompletionToken>
  74. static return_type initiate(
  75. ASIO_MOVE_ARG(Initiation) initiation,
  76. ASIO_MOVE_ARG(RawCompletionToken))
  77. {
  78. ASIO_MOVE_CAST(Initiation)(initiation)(
  79. detail::detached_handler(detached_t()));
  80. }
  81. #define ASIO_PRIVATE_INITIATE_DEF(n) \
  82. template <typename Initiation, typename RawCompletionToken, \
  83. ASIO_VARIADIC_TPARAMS(n)> \
  84. static return_type initiate( \
  85. ASIO_MOVE_ARG(Initiation) initiation, \
  86. ASIO_MOVE_ARG(RawCompletionToken), \
  87. ASIO_VARIADIC_MOVE_PARAMS(n)) \
  88. { \
  89. ASIO_MOVE_CAST(Initiation)(initiation)( \
  90. detail::detached_handler(detached_t()), \
  91. ASIO_VARIADIC_MOVE_ARGS(n)); \
  92. } \
  93. /**/
  94. ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_INITIATE_DEF)
  95. #undef ASIO_PRIVATE_INITIATE_DEF
  96. #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
  97. };
  98. #endif // !defined(GENERATING_DOCUMENTATION)
  99. } // namespace asio
  100. #include "asio/detail/pop_options.hpp"
  101. #endif // ASIO_IMPL_DETACHED_HPP