PageRenderTime 11ms CodeModel.GetById 7ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/asio/detail/pipe_select_interrupter.hpp

http://hadesmem.googlecode.com/
C++ Header | 89 lines | 44 code | 21 blank | 24 comment | 1 complexity | f9e9652ba2de09c7bb71d53ceef2ce3c MD5 | raw file
 1//
 2// detail/pipe_select_interrupter.hpp
 3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4//
 5// Copyright (c) 2003-2011 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 BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
12#define BOOST_ASIO_DETAIL_PIPE_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 <boost/asio/detail/config.hpp>
19
20#if !defined(BOOST_WINDOWS)
21#if !defined(__CYGWIN__)
22#if !defined(__SYMBIAN32__)
23#if !defined(BOOST_ASIO_HAS_EVENTFD)
24
25#include <boost/asio/detail/push_options.hpp>
26
27namespace boost {
28namespace asio {
29namespace detail {
30
31class pipe_select_interrupter
32{
33public:
34  // Constructor.
35  BOOST_ASIO_DECL pipe_select_interrupter();
36
37  // Destructor.
38  BOOST_ASIO_DECL ~pipe_select_interrupter();
39
40  // Recreate the interrupter's descriptors. Used after a fork.
41  BOOST_ASIO_DECL void recreate();
42
43  // Interrupt the select call.
44  BOOST_ASIO_DECL void interrupt();
45
46  // Reset the select interrupt. Returns true if the call was interrupted.
47  BOOST_ASIO_DECL bool reset();
48
49  // Get the read descriptor to be passed to select.
50  int read_descriptor() const
51  {
52    return read_descriptor_;
53  }
54
55private:
56  // Open the descriptors. Throws on error.
57  BOOST_ASIO_DECL void open_descriptors();
58
59  // Close the descriptors.
60  BOOST_ASIO_DECL void close_descriptors();
61
62  // The read end of a connection used to interrupt the select call. This file
63  // descriptor is passed to select such that when it is time to stop, a single
64  // byte will be written on the other end of the connection and this
65  // descriptor will become readable.
66  int read_descriptor_;
67
68  // The write end of a connection used to interrupt the select call. A single
69  // byte may be written to this to wake up the select which is waiting for the
70  // other end to become readable.
71  int write_descriptor_;
72};
73
74} // namespace detail
75} // namespace asio
76} // namespace boost
77
78#include <boost/asio/detail/pop_options.hpp>
79
80#if defined(BOOST_ASIO_HEADER_ONLY)
81# include <boost/asio/detail/impl/pipe_select_interrupter.ipp>
82#endif // defined(BOOST_ASIO_HEADER_ONLY)
83
84#endif // !defined(BOOST_ASIO_HAS_EVENTFD)
85#endif // !defined(__SYMBIAN32__)
86#endif // !defined(__CYGWIN__)
87#endif // !defined(BOOST_WINDOWS)
88
89#endif // BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP