2 // detail/pipe_select_interrupter.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
12 #define BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if !defined(BOOST_ASIO_WINDOWS)
21 #if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
22 #if !defined(__CYGWIN__)
23 #if !defined(__SYMBIAN32__)
24 #if !defined(BOOST_ASIO_HAS_EVENTFD)
26 #include <boost/asio/detail/push_options.hpp>
32 class pipe_select_interrupter
36 BOOST_ASIO_DECL pipe_select_interrupter();
39 BOOST_ASIO_DECL ~pipe_select_interrupter();
41 // Recreate the interrupter's descriptors. Used after a fork.
42 BOOST_ASIO_DECL void recreate();
44 // Interrupt the select call.
45 BOOST_ASIO_DECL void interrupt();
47 // Reset the select interrupt. Returns true if the call was interrupted.
48 BOOST_ASIO_DECL bool reset();
50 // Get the read descriptor to be passed to select.
51 int read_descriptor() const
53 return read_descriptor_;
57 // Open the descriptors. Throws on error.
58 BOOST_ASIO_DECL void open_descriptors();
60 // Close the descriptors.
61 BOOST_ASIO_DECL void close_descriptors();
63 // The read end of a connection used to interrupt the select call. This file
64 // descriptor is passed to select such that when it is time to stop, a single
65 // byte will be written on the other end of the connection and this
66 // descriptor will become readable.
69 // The write end of a connection used to interrupt the select call. A single
70 // byte may be written to this to wake up the select which is waiting for the
71 // other end to become readable.
72 int write_descriptor_;
79 #include <boost/asio/detail/pop_options.hpp>
81 #if defined(BOOST_ASIO_HEADER_ONLY)
82 # include <boost/asio/detail/impl/pipe_select_interrupter.ipp>
83 #endif // defined(BOOST_ASIO_HEADER_ONLY)
85 #endif // !defined(BOOST_ASIO_HAS_EVENTFD)
86 #endif // !defined(__SYMBIAN32__)
87 #endif // !defined(__CYGWIN__)
88 #endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
89 #endif // !defined(BOOST_ASIO_WINDOWS)
91 #endif // BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP