Chris@16: // Chris@16: // detail/pipe_select_interrupter.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP Chris@16: #define BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_ASIO_WINDOWS) Chris@16: #if !defined(BOOST_ASIO_WINDOWS_RUNTIME) Chris@16: #if !defined(__CYGWIN__) Chris@16: #if !defined(__SYMBIAN32__) Chris@16: #if !defined(BOOST_ASIO_HAS_EVENTFD) Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: Chris@16: class pipe_select_interrupter Chris@16: { Chris@16: public: Chris@16: // Constructor. Chris@16: BOOST_ASIO_DECL pipe_select_interrupter(); Chris@16: Chris@16: // Destructor. Chris@16: BOOST_ASIO_DECL ~pipe_select_interrupter(); Chris@16: Chris@16: // Recreate the interrupter's descriptors. Used after a fork. Chris@16: BOOST_ASIO_DECL void recreate(); Chris@16: Chris@16: // Interrupt the select call. Chris@16: BOOST_ASIO_DECL void interrupt(); Chris@16: Chris@16: // Reset the select interrupt. Returns true if the call was interrupted. Chris@16: BOOST_ASIO_DECL bool reset(); Chris@16: Chris@16: // Get the read descriptor to be passed to select. Chris@16: int read_descriptor() const Chris@16: { Chris@16: return read_descriptor_; Chris@16: } Chris@16: Chris@16: private: Chris@16: // Open the descriptors. Throws on error. Chris@16: BOOST_ASIO_DECL void open_descriptors(); Chris@16: Chris@16: // Close the descriptors. Chris@16: BOOST_ASIO_DECL void close_descriptors(); Chris@16: Chris@16: // The read end of a connection used to interrupt the select call. This file Chris@16: // descriptor is passed to select such that when it is time to stop, a single Chris@16: // byte will be written on the other end of the connection and this Chris@16: // descriptor will become readable. Chris@16: int read_descriptor_; Chris@16: Chris@16: // The write end of a connection used to interrupt the select call. A single Chris@16: // byte may be written to this to wake up the select which is waiting for the Chris@16: // other end to become readable. Chris@16: int write_descriptor_; Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_HEADER_ONLY) Chris@16: # include Chris@16: #endif // defined(BOOST_ASIO_HEADER_ONLY) Chris@16: Chris@16: #endif // !defined(BOOST_ASIO_HAS_EVENTFD) Chris@16: #endif // !defined(__SYMBIAN32__) Chris@16: #endif // !defined(__CYGWIN__) Chris@16: #endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME) Chris@16: #endif // !defined(BOOST_ASIO_WINDOWS) Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP