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.

92 lines
2.4KB

  1. //
  2. // detail/socket_select_interrupter.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_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP
  11. #define ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_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_WINDOWS_RUNTIME)
  17. #if defined(ASIO_WINDOWS) \
  18. || defined(__CYGWIN__) \
  19. || defined(__SYMBIAN32__)
  20. #include "asio/detail/socket_types.hpp"
  21. #include "asio/detail/push_options.hpp"
  22. namespace asio {
  23. namespace detail {
  24. class socket_select_interrupter
  25. {
  26. public:
  27. // Constructor.
  28. ASIO_DECL socket_select_interrupter();
  29. // Destructor.
  30. ASIO_DECL ~socket_select_interrupter();
  31. // Recreate the interrupter's descriptors. Used after a fork.
  32. ASIO_DECL void recreate();
  33. // Interrupt the select call.
  34. ASIO_DECL void interrupt();
  35. // Reset the select interrupt. Returns true if the call was interrupted.
  36. ASIO_DECL bool reset();
  37. // Get the read descriptor to be passed to select.
  38. socket_type read_descriptor() const
  39. {
  40. return read_descriptor_;
  41. }
  42. private:
  43. // Open the descriptors. Throws on error.
  44. ASIO_DECL void open_descriptors();
  45. // Close the descriptors.
  46. ASIO_DECL void close_descriptors();
  47. // The read end of a connection used to interrupt the select call. This file
  48. // descriptor is passed to select such that when it is time to stop, a single
  49. // byte will be written on the other end of the connection and this
  50. // descriptor will become readable.
  51. socket_type read_descriptor_;
  52. // The write end of a connection used to interrupt the select call. A single
  53. // byte may be written to this to wake up the select which is waiting for the
  54. // other end to become readable.
  55. socket_type write_descriptor_;
  56. };
  57. } // namespace detail
  58. } // namespace asio
  59. #include "asio/detail/pop_options.hpp"
  60. #if defined(ASIO_HEADER_ONLY)
  61. # include "asio/detail/impl/socket_select_interrupter.ipp"
  62. #endif // defined(ASIO_HEADER_ONLY)
  63. #endif // defined(ASIO_WINDOWS)
  64. // || defined(__CYGWIN__)
  65. // || defined(__SYMBIAN32__)
  66. #endif // !defined(ASIO_WINDOWS_RUNTIME)
  67. #endif // ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP