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.

use_awaitable.hpp 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // use_awaitable.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_USE_AWAITABLE_HPP
  11. #define ASIO_USE_AWAITABLE_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. #if defined(ASIO_HAS_CO_AWAIT) || defined(GENERATING_DOCUMENTATION)
  17. #include "asio/awaitable.hpp"
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. /// A completion token that represents the currently executing coroutine.
  21. /**
  22. * The @c use_awaitable_t class, with its value @c use_awaitable, is used to
  23. * represent the currently executing coroutine. This completion token may be
  24. * passed as a handler to an asynchronous operation. For example:
  25. *
  26. * @code awaitable<void> my_coroutine()
  27. * {
  28. * std::size_t n = co_await my_socket.async_read_some(buffer, use_awaitable);
  29. * ...
  30. * } @endcode
  31. *
  32. * When used with co_await, the initiating function (@c async_read_some in the
  33. * above example) suspends the current coroutine. The coroutine is resumed when
  34. * the asynchronous operation completes, and the result of the operation is
  35. * returned.
  36. */
  37. template <typename Executor = executor>
  38. struct use_awaitable_t
  39. {
  40. ASIO_CONSTEXPR use_awaitable_t()
  41. {
  42. }
  43. };
  44. /// A completion token object that represents the currently executing coroutine.
  45. /**
  46. * See the documentation for asio::use_awaitable_t for a usage example.
  47. */
  48. #if defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
  49. constexpr use_awaitable_t<> use_awaitable;
  50. #elif defined(ASIO_MSVC)
  51. __declspec(selectany) use_awaitable_t<> use_awaitable;
  52. #endif
  53. } // namespace asio
  54. #include "asio/detail/pop_options.hpp"
  55. #include "asio/impl/use_awaitable.hpp"
  56. #endif // defined(ASIO_HAS_CO_AWAIT) || defined(GENERATING_DOCUMENTATION)
  57. #endif // ASIO_USE_AWAITABLE_HPP