2 // detail/socket_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_SOCKET_SELECT_INTERRUPTER_HPP
12 #define BOOST_ASIO_DETAIL_SOCKET_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_RUNTIME)
22 #if defined(BOOST_ASIO_WINDOWS) \
23 || defined(__CYGWIN__) \
24 || defined(__SYMBIAN32__)
26 #include <boost/asio/detail/socket_types.hpp>
28 #include <boost/asio/detail/push_options.hpp>
34 class socket_select_interrupter
38 BOOST_ASIO_DECL socket_select_interrupter();
41 BOOST_ASIO_DECL ~socket_select_interrupter();
43 // Recreate the interrupter's descriptors. Used after a fork.
44 BOOST_ASIO_DECL void recreate();
46 // Interrupt the select call.
47 BOOST_ASIO_DECL void interrupt();
49 // Reset the select interrupt. Returns true if the call was interrupted.
50 BOOST_ASIO_DECL bool reset();
52 // Get the read descriptor to be passed to select.
53 socket_type read_descriptor() const
55 return read_descriptor_;
59 // Open the descriptors. Throws on error.
60 BOOST_ASIO_DECL void open_descriptors();
62 // Close the descriptors.
63 BOOST_ASIO_DECL void close_descriptors();
65 // The read end of a connection used to interrupt the select call. This file
66 // descriptor is passed to select such that when it is time to stop, a single
67 // byte will be written on the other end of the connection and this
68 // descriptor will become readable.
69 socket_type read_descriptor_;
71 // The write end of a connection used to interrupt the select call. A single
72 // byte may be written to this to wake up the select which is waiting for the
73 // other end to become readable.
74 socket_type write_descriptor_;
81 #include <boost/asio/detail/pop_options.hpp>
83 #if defined(BOOST_ASIO_HEADER_ONLY)
84 # include <boost/asio/detail/impl/socket_select_interrupter.ipp>
85 #endif // defined(BOOST_ASIO_HEADER_ONLY)
87 #endif // defined(BOOST_ASIO_WINDOWS)
88 // || defined(__CYGWIN__)
89 // || defined(__SYMBIAN32__)
91 #endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
93 #endif // BOOST_ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP