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.

109 lines
3.8KB

  1. //
  2. // dispatch.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_DISPATCH_HPP
  11. #define ASIO_DISPATCH_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/type_traits.hpp"
  18. #include "asio/execution_context.hpp"
  19. #include "asio/is_executor.hpp"
  20. #include "asio/detail/push_options.hpp"
  21. namespace asio {
  22. /// Submits a completion token or function object for execution.
  23. /**
  24. * This function submits an object for execution using the object's associated
  25. * executor. The function object may be called from the current thread prior to
  26. * returning from <tt>dispatch()</tt>. Otherwise, it is queued for execution.
  27. *
  28. * This function has the following effects:
  29. *
  30. * @li Constructs a function object handler of type @c Handler, initialized
  31. * with <tt>handler(forward<CompletionToken>(token))</tt>.
  32. *
  33. * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
  34. * initializing the object as <tt>result(handler)</tt>.
  35. *
  36. * @li Obtains the handler's associated executor object @c ex by performing
  37. * <tt>get_associated_executor(handler)</tt>.
  38. *
  39. * @li Obtains the handler's associated allocator object @c alloc by performing
  40. * <tt>get_associated_allocator(handler)</tt>.
  41. *
  42. * @li Performs <tt>ex.dispatch(std::move(handler), alloc)</tt>.
  43. *
  44. * @li Returns <tt>result.get()</tt>.
  45. */
  46. template <typename CompletionToken>
  47. ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  48. ASIO_MOVE_ARG(CompletionToken) token);
  49. /// Submits a completion token or function object for execution.
  50. /**
  51. * This function submits an object for execution using the specified executor.
  52. * The function object may be called from the current thread prior to returning
  53. * from <tt>dispatch()</tt>. Otherwise, it is queued for execution.
  54. *
  55. * This function has the following effects:
  56. *
  57. * @li Constructs a function object handler of type @c Handler, initialized
  58. * with <tt>handler(forward<CompletionToken>(token))</tt>.
  59. *
  60. * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
  61. * initializing the object as <tt>result(handler)</tt>.
  62. *
  63. * @li Obtains the handler's associated executor object @c ex1 by performing
  64. * <tt>get_associated_executor(handler)</tt>.
  65. *
  66. * @li Creates a work object @c w by performing <tt>make_work(ex1)</tt>.
  67. *
  68. * @li Obtains the handler's associated allocator object @c alloc by performing
  69. * <tt>get_associated_allocator(handler)</tt>.
  70. *
  71. * @li Constructs a function object @c f with a function call operator that
  72. * performs <tt>ex1.dispatch(std::move(handler), alloc)</tt> followed by
  73. * <tt>w.reset()</tt>.
  74. *
  75. * @li Performs <tt>Executor(ex).dispatch(std::move(f), alloc)</tt>.
  76. *
  77. * @li Returns <tt>result.get()</tt>.
  78. */
  79. template <typename Executor, typename CompletionToken>
  80. ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  81. const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token,
  82. typename enable_if<is_executor<Executor>::value>::type* = 0);
  83. /// Submits a completion token or function object for execution.
  84. /**
  85. * @returns <tt>dispatch(ctx.get_executor(),
  86. * forward<CompletionToken>(token))</tt>.
  87. */
  88. template <typename ExecutionContext, typename CompletionToken>
  89. ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  90. ExecutionContext& ctx, ASIO_MOVE_ARG(CompletionToken) token,
  91. typename enable_if<is_convertible<
  92. ExecutionContext&, execution_context&>::value>::type* = 0);
  93. } // namespace asio
  94. #include "asio/detail/pop_options.hpp"
  95. #include "asio/impl/dispatch.hpp"
  96. #endif // ASIO_DISPATCH_HPP