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

http://hadesmem.googlecode.com/ · C++ Header · 89 lines · 41 code · 22 blank · 26 comment · 3 complexity · 2d9c828613f09f0e61e8ce778b2f73be MD5 · raw file

  1. //
  2. // detail/socket_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_SOCKET_SELECT_INTERRUPTER_HPP
  11. #define BOOST_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 <boost/asio/detail/config.hpp>
  16. #if defined(BOOST_WINDOWS) \
  17. || defined(__CYGWIN__) \
  18. || defined(__SYMBIAN32__)
  19. #include <boost/asio/detail/socket_types.hpp>
  20. #include <boost/asio/detail/push_options.hpp>
  21. namespace boost {
  22. namespace asio {
  23. namespace detail {
  24. class socket_select_interrupter
  25. {
  26. public:
  27. // Constructor.
  28. BOOST_ASIO_DECL socket_select_interrupter();
  29. // Destructor.
  30. BOOST_ASIO_DECL ~socket_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. socket_type 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. 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. } // namespace boost
  60. #include <boost/asio/detail/pop_options.hpp>
  61. #if defined(BOOST_ASIO_HEADER_ONLY)
  62. # include <boost/asio/detail/impl/socket_select_interrupter.ipp>
  63. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  64. #endif // defined(BOOST_WINDOWS)
  65. // || defined(__CYGWIN__)
  66. // || defined(__SYMBIAN32__)
  67. #endif // BOOST_ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP