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.

78 lines
2.3KB

  1. //
  2. // impl/dispatch.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_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. template <typename CompletionToken>
  22. ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  23. ASIO_MOVE_ARG(CompletionToken) token)
  24. {
  25. typedef typename handler_type<CompletionToken, void()>::type handler;
  26. async_completion<CompletionToken, void()> completion(token);
  27. typename associated_executor<handler>::type ex(
  28. (get_associated_executor)(completion.handler));
  29. typename associated_allocator<handler>::type alloc(
  30. (get_associated_allocator)(completion.handler));
  31. ex.dispatch(ASIO_MOVE_CAST(handler)(completion.handler), alloc);
  32. return completion.result.get();
  33. }
  34. template <typename Executor, typename CompletionToken>
  35. ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  36. const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token,
  37. typename enable_if<is_executor<Executor>::value>::type*)
  38. {
  39. typedef typename handler_type<CompletionToken, void()>::type handler;
  40. async_completion<CompletionToken, void()> completion(token);
  41. Executor ex1(ex);
  42. typename associated_allocator<handler>::type alloc(
  43. (get_associated_allocator)(completion.handler));
  44. ex1.dispatch(detail::work_dispatcher<handler>(completion.handler), alloc);
  45. return completion.result.get();
  46. }
  47. template <typename ExecutionContext, typename CompletionToken>
  48. inline ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
  49. ExecutionContext& ctx, ASIO_MOVE_ARG(CompletionToken) token,
  50. typename enable_if<is_convertible<
  51. ExecutionContext&, execution_context&>::value>::type*)
  52. {
  53. return (dispatch)(ctx.get_executor(),
  54. ASIO_MOVE_CAST(CompletionToken)(token));
  55. }
  56. } // namespace asio
  57. #include "asio/detail/pop_options.hpp"
  58. #endif // ASIO_IMPL_DISPATCH_HPP