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.

84 lines
2.3KB

  1. //
  2. // detail/eventfd_select_interrupter.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. // Copyright (c) 2008 Roelof Naude (roelof.naude at gmail dot com)
  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_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP
  12. #define ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_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_EVENTFD)
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. namespace detail {
  21. class eventfd_select_interrupter
  22. {
  23. public:
  24. // Constructor.
  25. ASIO_DECL eventfd_select_interrupter();
  26. // Destructor.
  27. ASIO_DECL ~eventfd_select_interrupter();
  28. // Recreate the interrupter's descriptors. Used after a fork.
  29. ASIO_DECL void recreate();
  30. // Interrupt the select call.
  31. ASIO_DECL void interrupt();
  32. // Reset the select interrupt. Returns true if the call was interrupted.
  33. ASIO_DECL bool reset();
  34. // Get the read descriptor to be passed to select.
  35. int read_descriptor() const
  36. {
  37. return read_descriptor_;
  38. }
  39. private:
  40. // Open the descriptors. Throws on error.
  41. ASIO_DECL void open_descriptors();
  42. // Close the descriptors.
  43. ASIO_DECL void close_descriptors();
  44. // The read end of a connection used to interrupt the select call. This file
  45. // descriptor is passed to select such that when it is time to stop, a single
  46. // 64bit value will be written on the other end of the connection and this
  47. // descriptor will become readable.
  48. int read_descriptor_;
  49. // The write end of a connection used to interrupt the select call. A single
  50. // 64bit non-zero value may be written to this to wake up the select which is
  51. // waiting for the other end to become readable. This descriptor will only
  52. // differ from the read descriptor when a pipe is used.
  53. int write_descriptor_;
  54. };
  55. } // namespace detail
  56. } // namespace asio
  57. #include "asio/detail/pop_options.hpp"
  58. #if defined(ASIO_HEADER_ONLY)
  59. # include "asio/detail/impl/eventfd_select_interrupter.ipp"
  60. #endif // defined(ASIO_HEADER_ONLY)
  61. #endif // defined(ASIO_HAS_EVENTFD)
  62. #endif // ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP