Chris@16
|
1 //
|
Chris@16
|
2 // detail/pipe_select_interrupter.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
|
Chris@16
|
12 #define BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/asio/detail/config.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #if !defined(BOOST_ASIO_WINDOWS)
|
Chris@16
|
21 #if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
Chris@16
|
22 #if !defined(__CYGWIN__)
|
Chris@16
|
23 #if !defined(__SYMBIAN32__)
|
Chris@16
|
24 #if !defined(BOOST_ASIO_HAS_EVENTFD)
|
Chris@16
|
25
|
Chris@16
|
26 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 namespace boost {
|
Chris@16
|
29 namespace asio {
|
Chris@16
|
30 namespace detail {
|
Chris@16
|
31
|
Chris@16
|
32 class pipe_select_interrupter
|
Chris@16
|
33 {
|
Chris@16
|
34 public:
|
Chris@16
|
35 // Constructor.
|
Chris@16
|
36 BOOST_ASIO_DECL pipe_select_interrupter();
|
Chris@16
|
37
|
Chris@16
|
38 // Destructor.
|
Chris@16
|
39 BOOST_ASIO_DECL ~pipe_select_interrupter();
|
Chris@16
|
40
|
Chris@16
|
41 // Recreate the interrupter's descriptors. Used after a fork.
|
Chris@16
|
42 BOOST_ASIO_DECL void recreate();
|
Chris@16
|
43
|
Chris@16
|
44 // Interrupt the select call.
|
Chris@16
|
45 BOOST_ASIO_DECL void interrupt();
|
Chris@16
|
46
|
Chris@16
|
47 // Reset the select interrupt. Returns true if the call was interrupted.
|
Chris@16
|
48 BOOST_ASIO_DECL bool reset();
|
Chris@16
|
49
|
Chris@16
|
50 // Get the read descriptor to be passed to select.
|
Chris@16
|
51 int read_descriptor() const
|
Chris@16
|
52 {
|
Chris@16
|
53 return read_descriptor_;
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56 private:
|
Chris@16
|
57 // Open the descriptors. Throws on error.
|
Chris@16
|
58 BOOST_ASIO_DECL void open_descriptors();
|
Chris@16
|
59
|
Chris@16
|
60 // Close the descriptors.
|
Chris@16
|
61 BOOST_ASIO_DECL void close_descriptors();
|
Chris@16
|
62
|
Chris@16
|
63 // The read end of a connection used to interrupt the select call. This file
|
Chris@16
|
64 // descriptor is passed to select such that when it is time to stop, a single
|
Chris@16
|
65 // byte will be written on the other end of the connection and this
|
Chris@16
|
66 // descriptor will become readable.
|
Chris@16
|
67 int read_descriptor_;
|
Chris@16
|
68
|
Chris@16
|
69 // The write end of a connection used to interrupt the select call. A single
|
Chris@16
|
70 // byte may be written to this to wake up the select which is waiting for the
|
Chris@16
|
71 // other end to become readable.
|
Chris@16
|
72 int write_descriptor_;
|
Chris@16
|
73 };
|
Chris@16
|
74
|
Chris@16
|
75 } // namespace detail
|
Chris@16
|
76 } // namespace asio
|
Chris@16
|
77 } // namespace boost
|
Chris@16
|
78
|
Chris@16
|
79 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
80
|
Chris@16
|
81 #if defined(BOOST_ASIO_HEADER_ONLY)
|
Chris@16
|
82 # include <boost/asio/detail/impl/pipe_select_interrupter.ipp>
|
Chris@16
|
83 #endif // defined(BOOST_ASIO_HEADER_ONLY)
|
Chris@16
|
84
|
Chris@16
|
85 #endif // !defined(BOOST_ASIO_HAS_EVENTFD)
|
Chris@16
|
86 #endif // !defined(__SYMBIAN32__)
|
Chris@16
|
87 #endif // !defined(__CYGWIN__)
|
Chris@16
|
88 #endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
Chris@16
|
89 #endif // !defined(BOOST_ASIO_WINDOWS)
|
Chris@16
|
90
|
Chris@16
|
91 #endif // BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
|