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.

dispatch.hpp 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // impl/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_IMPL_DISPATCH_HPP
  11. #define ASIO_IMPL_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/associated_allocator.hpp"
  17. #include "asio/associated_executor.hpp"
  18. #include "asio/detail/work_dispatcher.hpp"
  19. #include "asio/detail/push_options.hpp"
  20. namespace asio {
  21. namespace detail {
  22. struct initiate_dispatch
  23. {
  24. template <typename CompletionHandler>
  25. void operator()(ASIO_MOVE_ARG(CompletionHandler) handler) const
  26. {
  27. typedef typename decay<CompletionHandler>::type DecayedHandler;
  28. typename associated_executor<DecayedHandler>::type ex(
  29. (get_associated_executor)(handler));
  30. typename associated_allocator<DecayedHandler>::type alloc(
  31. (get_associated_allocator)(handler));
  32. ex.dispatch(ASIO_MOVE_CAST(CompletionHandler)(handler), alloc);
  33. }
  34. template <typename CompletionHandler, typename Executor>
  35. void operator()(ASIO_MOVE_ARG(CompletionHandler) handler,
  36. ASIO_MOVE_ARG(Executor) ex) const
  37. {
  38. typedef typename decay<CompletionHandler>::type DecayedHandler;
  39. typename associated_allocator<DecayedHandler>::type alloc(
  40. (get_associated_allocator)(handler));
  41. ex.dispatch(detail::work_dispatcher<DecayedHandler>(
  42. ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc);
  43. }
  44. };
  45. } // namespace detail
  46. template <typename CompletionToken>
  47. ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  48. ASIO_MOVE_ARG(CompletionToken) token)
  49. {
  50. return async_initiate<CompletionToken, void()>(
  51. detail::initiate_dispatch(), token);
  52. }
  53. template <typename Executor, typename CompletionToken>
  54. ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  55. const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token,
  56. typename enable_if<is_executor<Executor>::value>::type*)
  57. {
  58. return async_initiate<CompletionToken, void()>(
  59. detail::initiate_dispatch(), token, ex);
  60. }
  61. template <typename ExecutionContext, typename CompletionToken>
  62. inline ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  63. ExecutionContext& ctx, ASIO_MOVE_ARG(CompletionToken) token,
  64. typename enable_if<is_convertible<
  65. ExecutionContext&, execution_context&>::value>::type*)
  66. {
  67. return (dispatch)(ctx.get_executor(),
  68. ASIO_MOVE_CAST(CompletionToken)(token));
  69. }
  70. } // namespace asio
  71. #include "asio/detail/pop_options.hpp"
  72. #endif // ASIO_IMPL_DISPATCH_HPP