PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

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