Realistic 3D camera system
3D camera system components
eventfd_select_interrupter.hpp
Go to the documentation of this file.
1 //
2 // detail/eventfd_select_interrupter.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Copyright (c) 2008 Roelof Naude (roelof.naude at gmail dot com)
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 //
11 
12 #ifndef ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP
13 #define ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP
14 
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 
19 #include "asio/detail/config.hpp"
20 
21 #if defined(ASIO_HAS_EVENTFD)
22 
24 
25 namespace asio {
26 namespace detail {
27 
28 class eventfd_select_interrupter
29 {
30 public:
31  // Constructor.
32  ASIO_DECL eventfd_select_interrupter();
33 
34  // Destructor.
35  ASIO_DECL ~eventfd_select_interrupter();
36 
37  // Recreate the interrupter's descriptors. Used after a fork.
38  ASIO_DECL void recreate();
39 
40  // Interrupt the select call.
41  ASIO_DECL void interrupt();
42 
43  // Reset the select interrupt. Returns true if the call was interrupted.
44  ASIO_DECL bool reset();
45 
46  // Get the read descriptor to be passed to select.
47  int read_descriptor() const
48  {
49  return read_descriptor_;
50  }
51 
52 private:
53  // Open the descriptors. Throws on error.
54  ASIO_DECL void open_descriptors();
55 
56  // Close the descriptors.
57  ASIO_DECL void close_descriptors();
58 
59  // The read end of a connection used to interrupt the select call. This file
60  // descriptor is passed to select such that when it is time to stop, a single
61  // 64bit value will be written on the other end of the connection and this
62  // descriptor will become readable.
63  int read_descriptor_;
64 
65  // The write end of a connection used to interrupt the select call. A single
66  // 64bit non-zero value may be written to this to wake up the select which is
67  // waiting for the other end to become readable. This descriptor will only
68  // differ from the read descriptor when a pipe is used.
69  int write_descriptor_;
70 };
71 
72 } // namespace detail
73 } // namespace asio
74 
76 
77 #if defined(ASIO_HEADER_ONLY)
79 #endif // defined(ASIO_HEADER_ONLY)
80 
81 #endif // defined(ASIO_HAS_EVENTFD)
82 
83 #endif // ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP
#define ASIO_DECL
Definition: config.hpp:43