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.

134 lines
3.4KB

  1. //
  2. // signal_set_service.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_SIGNAL_SET_SERVICE_HPP
  11. #define ASIO_SIGNAL_SET_SERVICE_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/signal_set_service.hpp"
  18. #include "asio/error.hpp"
  19. #include "asio/io_context.hpp"
  20. #include "asio/detail/push_options.hpp"
  21. namespace asio {
  22. /// Default service implementation for a signal set.
  23. class signal_set_service
  24. #if defined(GENERATING_DOCUMENTATION)
  25. : public asio::io_context::service
  26. #else
  27. : public asio::detail::service_base<signal_set_service>
  28. #endif
  29. {
  30. public:
  31. #if defined(GENERATING_DOCUMENTATION)
  32. /// The unique service identifier.
  33. static asio::io_context::id id;
  34. #endif
  35. public:
  36. /// The type of a signal set implementation.
  37. #if defined(GENERATING_DOCUMENTATION)
  38. typedef implementation_defined implementation_type;
  39. #else
  40. typedef detail::signal_set_service::implementation_type implementation_type;
  41. #endif
  42. /// Construct a new signal set service for the specified io_context.
  43. explicit signal_set_service(asio::io_context& io_context)
  44. : asio::detail::service_base<signal_set_service>(io_context),
  45. service_impl_(io_context)
  46. {
  47. }
  48. /// Construct a new signal set implementation.
  49. void construct(implementation_type& impl)
  50. {
  51. service_impl_.construct(impl);
  52. }
  53. /// Destroy a signal set implementation.
  54. void destroy(implementation_type& impl)
  55. {
  56. service_impl_.destroy(impl);
  57. }
  58. /// Add a signal to a signal_set.
  59. asio::error_code add(implementation_type& impl,
  60. int signal_number, asio::error_code& ec)
  61. {
  62. return service_impl_.add(impl, signal_number, ec);
  63. }
  64. /// Remove a signal to a signal_set.
  65. asio::error_code remove(implementation_type& impl,
  66. int signal_number, asio::error_code& ec)
  67. {
  68. return service_impl_.remove(impl, signal_number, ec);
  69. }
  70. /// Remove all signals from a signal_set.
  71. asio::error_code clear(implementation_type& impl,
  72. asio::error_code& ec)
  73. {
  74. return service_impl_.clear(impl, ec);
  75. }
  76. /// Cancel all operations associated with the signal set.
  77. asio::error_code cancel(implementation_type& impl,
  78. asio::error_code& ec)
  79. {
  80. return service_impl_.cancel(impl, ec);
  81. }
  82. // Start an asynchronous operation to wait for a signal to be delivered.
  83. template <typename SignalHandler>
  84. ASIO_INITFN_RESULT_TYPE(SignalHandler,
  85. void (asio::error_code, int))
  86. async_wait(implementation_type& impl,
  87. ASIO_MOVE_ARG(SignalHandler) handler)
  88. {
  89. async_completion<SignalHandler,
  90. void (asio::error_code, int)> init(handler);
  91. service_impl_.async_wait(impl, init.handler);
  92. return init.result.get();
  93. }
  94. private:
  95. // Destroy all user-defined handler objects owned by the service.
  96. void shutdown()
  97. {
  98. service_impl_.shutdown();
  99. }
  100. // Perform any fork-related housekeeping.
  101. void notify_fork(asio::io_context::fork_event event)
  102. {
  103. service_impl_.notify_fork(event);
  104. }
  105. // The platform-specific implementation.
  106. detail::signal_set_service service_impl_;
  107. };
  108. } // namespace asio
  109. #include "asio/detail/pop_options.hpp"
  110. #endif // ASIO_SIGNAL_SET_SERVICE_HPP