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.

114 lines
4.0KB

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