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.

object_handle_service.hpp 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //
  2. // windows/object_handle_service.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. // Copyright (c) 2011 Boris Schaeling (boris@highscore.de)
  7. //
  8. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  9. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. #ifndef ASIO_WINDOWS_OBJECT_HANDLE_SERVICE_HPP
  12. #define ASIO_WINDOWS_OBJECT_HANDLE_SERVICE_HPP
  13. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  14. # pragma once
  15. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  16. #include "asio/detail/config.hpp"
  17. #if defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE) \
  18. || defined(GENERATING_DOCUMENTATION)
  19. #include "asio/async_result.hpp"
  20. #include "asio/detail/win_object_handle_service.hpp"
  21. #include "asio/error.hpp"
  22. #include "asio/io_context.hpp"
  23. #include "asio/detail/push_options.hpp"
  24. namespace asio {
  25. namespace windows {
  26. /// Default service implementation for an object handle.
  27. class object_handle_service
  28. #if defined(GENERATING_DOCUMENTATION)
  29. : public asio::io_context::service
  30. #else
  31. : public asio::detail::service_base<object_handle_service>
  32. #endif
  33. {
  34. public:
  35. #if defined(GENERATING_DOCUMENTATION)
  36. /// The unique service identifier.
  37. static asio::io_context::id id;
  38. #endif
  39. private:
  40. // The type of the platform-specific implementation.
  41. typedef detail::win_object_handle_service service_impl_type;
  42. public:
  43. /// The type of an object handle implementation.
  44. #if defined(GENERATING_DOCUMENTATION)
  45. typedef implementation_defined implementation_type;
  46. #else
  47. typedef service_impl_type::implementation_type implementation_type;
  48. #endif
  49. /// The native handle type.
  50. #if defined(GENERATING_DOCUMENTATION)
  51. typedef implementation_defined native_handle_type;
  52. #else
  53. typedef service_impl_type::native_handle_type native_handle_type;
  54. #endif
  55. /// Construct a new object handle service for the specified io_context.
  56. explicit object_handle_service(asio::io_context& io_context)
  57. : asio::detail::service_base<object_handle_service>(io_context),
  58. service_impl_(io_context)
  59. {
  60. }
  61. /// Construct a new object handle implementation.
  62. void construct(implementation_type& impl)
  63. {
  64. service_impl_.construct(impl);
  65. }
  66. #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  67. /// Move-construct a new object handle implementation.
  68. void move_construct(implementation_type& impl,
  69. implementation_type& other_impl)
  70. {
  71. service_impl_.move_construct(impl, other_impl);
  72. }
  73. /// Move-assign from another object handle implementation.
  74. void move_assign(implementation_type& impl,
  75. object_handle_service& other_service,
  76. implementation_type& other_impl)
  77. {
  78. service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
  79. }
  80. #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  81. /// Destroy an object handle implementation.
  82. void destroy(implementation_type& impl)
  83. {
  84. service_impl_.destroy(impl);
  85. }
  86. /// Assign an existing native handle to an object handle.
  87. asio::error_code assign(implementation_type& impl,
  88. const native_handle_type& handle, asio::error_code& ec)
  89. {
  90. return service_impl_.assign(impl, handle, ec);
  91. }
  92. /// Determine whether the handle is open.
  93. bool is_open(const implementation_type& impl) const
  94. {
  95. return service_impl_.is_open(impl);
  96. }
  97. /// Close an object handle implementation.
  98. asio::error_code close(implementation_type& impl,
  99. asio::error_code& ec)
  100. {
  101. return service_impl_.close(impl, ec);
  102. }
  103. /// Get the native handle implementation.
  104. native_handle_type native_handle(implementation_type& impl)
  105. {
  106. return service_impl_.native_handle(impl);
  107. }
  108. /// Cancel all asynchronous operations associated with the handle.
  109. asio::error_code cancel(implementation_type& impl,
  110. asio::error_code& ec)
  111. {
  112. return service_impl_.cancel(impl, ec);
  113. }
  114. // Wait for a signaled state.
  115. void wait(implementation_type& impl, asio::error_code& ec)
  116. {
  117. service_impl_.wait(impl, ec);
  118. }
  119. /// Start an asynchronous wait.
  120. template <typename WaitHandler>
  121. ASIO_INITFN_RESULT_TYPE(WaitHandler,
  122. void (asio::error_code))
  123. async_wait(implementation_type& impl,
  124. ASIO_MOVE_ARG(WaitHandler) handler)
  125. {
  126. asio::async_completion<WaitHandler,
  127. void (asio::error_code)> init(handler);
  128. service_impl_.async_wait(impl, init.handler);
  129. return init.result.get();
  130. }
  131. private:
  132. // Destroy all user-defined handler objects owned by the service.
  133. void shutdown()
  134. {
  135. service_impl_.shutdown();
  136. }
  137. // The platform-specific implementation.
  138. service_impl_type service_impl_;
  139. };
  140. } // namespace windows
  141. } // namespace asio
  142. #include "asio/detail/pop_options.hpp"
  143. #endif // defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE)
  144. // || defined(GENERATING_DOCUMENTATION)
  145. #endif // ASIO_WINDOWS_OBJECT_HANDLE_SERVICE_HPP