/Src/Dependencies/Boost/boost/asio/detail/pipe_select_interrupter.hpp

http://hadesmem.googlecode.com/ · C++ Header · 89 lines · 44 code · 21 blank · 24 comment · 1 complexity · f9e9652ba2de09c7bb71d53ceef2ce3c MD5 · raw file

  1. //
  2. // detail/pipe_select_interrupter.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2011 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 BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
  11. #define BOOST_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 <boost/asio/detail/config.hpp>
  16. #if !defined(BOOST_WINDOWS)
  17. #if !defined(__CYGWIN__)
  18. #if !defined(__SYMBIAN32__)
  19. #if !defined(BOOST_ASIO_HAS_EVENTFD)
  20. #include <boost/asio/detail/push_options.hpp>
  21. namespace boost {
  22. namespace asio {
  23. namespace detail {
  24. class pipe_select_interrupter
  25. {
  26. public:
  27. // Constructor.
  28. BOOST_ASIO_DECL pipe_select_interrupter();
  29. // Destructor.
  30. BOOST_ASIO_DECL ~pipe_select_interrupter();
  31. // Recreate the interrupter's descriptors. Used after a fork.
  32. BOOST_ASIO_DECL void recreate();
  33. // Interrupt the select call.
  34. BOOST_ASIO_DECL void interrupt();
  35. // Reset the select interrupt. Returns true if the call was interrupted.
  36. BOOST_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. BOOST_ASIO_DECL void open_descriptors();
  45. // Close the descriptors.
  46. BOOST_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. } // namespace boost
  60. #include <boost/asio/detail/pop_options.hpp>
  61. #if defined(BOOST_ASIO_HEADER_ONLY)
  62. # include <boost/asio/detail/impl/pipe_select_interrupter.ipp>
  63. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  64. #endif // !defined(BOOST_ASIO_HAS_EVENTFD)
  65. #endif // !defined(__SYMBIAN32__)
  66. #endif // !defined(__CYGWIN__)
  67. #endif // !defined(BOOST_WINDOWS)
  68. #endif // BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP