Realistic 3D camera system
3D camera system components
socket_select_interrupter.hpp
Go to the documentation of this file.
1 //
2 // detail/socket_select_interrupter.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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 
11 #ifndef ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP
12 #define ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
20 #if !defined(ASIO_WINDOWS_RUNTIME)
21 
22 #if defined(ASIO_WINDOWS) \
23  || defined(__CYGWIN__) \
24  || defined(__SYMBIAN32__)
25 
27 
29 
30 namespace asio {
31 namespace detail {
32 
33 class socket_select_interrupter
34 {
35 public:
36  // Constructor.
37  ASIO_DECL socket_select_interrupter();
38 
39  // Destructor.
40  ASIO_DECL ~socket_select_interrupter();
41 
42  // Recreate the interrupter's descriptors. Used after a fork.
43  ASIO_DECL void recreate();
44 
45  // Interrupt the select call.
46  ASIO_DECL void interrupt();
47 
48  // Reset the select interrupt. Returns true if the call was interrupted.
49  ASIO_DECL bool reset();
50 
51  // Get the read descriptor to be passed to select.
52  socket_type read_descriptor() const
53  {
54  return read_descriptor_;
55  }
56 
57 private:
58  // Open the descriptors. Throws on error.
59  ASIO_DECL void open_descriptors();
60 
61  // Close the descriptors.
62  ASIO_DECL void close_descriptors();
63 
64  // The read end of a connection used to interrupt the select call. This file
65  // descriptor is passed to select such that when it is time to stop, a single
66  // byte will be written on the other end of the connection and this
67  // descriptor will become readable.
68  socket_type read_descriptor_;
69 
70  // The write end of a connection used to interrupt the select call. A single
71  // byte may be written to this to wake up the select which is waiting for the
72  // other end to become readable.
73  socket_type write_descriptor_;
74 };
75 
76 } // namespace detail
77 } // namespace asio
78 
80 
81 #if defined(ASIO_HEADER_ONLY)
83 #endif // defined(ASIO_HEADER_ONLY)
84 
85 #endif // defined(ASIO_WINDOWS)
86  // || defined(__CYGWIN__)
87  // || defined(__SYMBIAN32__)
88 
89 #endif // !defined(ASIO_WINDOWS_RUNTIME)
90 
91 #endif // ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP
#define ASIO_DECL
Definition: config.hpp:43