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.

pipe_select_interrupter.hpp 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // detail/pipe_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_PIPE_SELECT_INTERRUPTER_HPP
  11. #define ASIO_DETAIL_PIPE_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)
  17. #if !defined(ASIO_WINDOWS_RUNTIME)
  18. #if !defined(__CYGWIN__)
  19. #if !defined(__SYMBIAN32__)
  20. #if !defined(ASIO_HAS_EVENTFD)
  21. #include "asio/detail/push_options.hpp"
  22. namespace asio {
  23. namespace detail {
  24. class pipe_select_interrupter
  25. {
  26. public:
  27. // Constructor.
  28. ASIO_DECL pipe_select_interrupter();
  29. // Destructor.
  30. ASIO_DECL ~pipe_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. int 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. int 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. int 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/pipe_select_interrupter.ipp"
  62. #endif // defined(ASIO_HEADER_ONLY)
  63. #endif // !defined(ASIO_HAS_EVENTFD)
  64. #endif // !defined(__SYMBIAN32__)
  65. #endif // !defined(__CYGWIN__)
  66. #endif // !defined(ASIO_WINDOWS_RUNTIME)
  67. #endif // !defined(ASIO_WINDOWS)
  68. #endif // ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP