Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / detail / resolver_service_base.hpp @ 2486

History | View | Annotate | Download (3.8 kB)

1 2486 sjacqu01
//
2 2486 sjacqu01
// detail/resolver_service_base.hpp
3 2486 sjacqu01
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 2486 sjacqu01
//
5 2486 sjacqu01
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 2486 sjacqu01
//
7 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8 2486 sjacqu01
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 2486 sjacqu01
//
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_ASIO_DETAIL_RESOLVER_SERVICE_BASE_HPP
12 2486 sjacqu01
#define BOOST_ASIO_DETAIL_RESOLVER_SERVICE_BASE_HPP
13 2486 sjacqu01
14 2486 sjacqu01
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 2486 sjacqu01
# pragma once
16 2486 sjacqu01
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 2486 sjacqu01
18 2486 sjacqu01
#include <boost/asio/detail/config.hpp>
19 2486 sjacqu01
#include <boost/asio/error.hpp>
20 2486 sjacqu01
#include <boost/asio/io_service.hpp>
21 2486 sjacqu01
#include <boost/asio/detail/mutex.hpp>
22 2486 sjacqu01
#include <boost/asio/detail/noncopyable.hpp>
23 2486 sjacqu01
#include <boost/asio/detail/operation.hpp>
24 2486 sjacqu01
#include <boost/asio/detail/socket_ops.hpp>
25 2486 sjacqu01
#include <boost/asio/detail/socket_types.hpp>
26 2486 sjacqu01
#include <boost/asio/detail/scoped_ptr.hpp>
27 2486 sjacqu01
#include <boost/asio/detail/thread.hpp>
28 2486 sjacqu01
29 2486 sjacqu01
#include <boost/asio/detail/push_options.hpp>
30 2486 sjacqu01
31 2486 sjacqu01
namespace boost {
32 2486 sjacqu01
namespace asio {
33 2486 sjacqu01
namespace detail {
34 2486 sjacqu01
35 2486 sjacqu01
class resolver_service_base
36 2486 sjacqu01
{
37 2486 sjacqu01
public:
38 2486 sjacqu01
  // The implementation type of the resolver. A cancellation token is used to
39 2486 sjacqu01
  // indicate to the background thread that the operation has been cancelled.
40 2486 sjacqu01
  typedef socket_ops::shared_cancel_token_type implementation_type;
41 2486 sjacqu01
42 2486 sjacqu01
  // Constructor.
43 2486 sjacqu01
  BOOST_ASIO_DECL resolver_service_base(boost::asio::io_service& io_service);
44 2486 sjacqu01
45 2486 sjacqu01
  // Destructor.
46 2486 sjacqu01
  BOOST_ASIO_DECL ~resolver_service_base();
47 2486 sjacqu01
48 2486 sjacqu01
  // Destroy all user-defined handler objects owned by the service.
49 2486 sjacqu01
  BOOST_ASIO_DECL void shutdown_service();
50 2486 sjacqu01
51 2486 sjacqu01
  // Perform any fork-related housekeeping.
52 2486 sjacqu01
  BOOST_ASIO_DECL void fork_service(
53 2486 sjacqu01
      boost::asio::io_service::fork_event fork_ev);
54 2486 sjacqu01
55 2486 sjacqu01
  // Construct a new resolver implementation.
56 2486 sjacqu01
  BOOST_ASIO_DECL void construct(implementation_type& impl);
57 2486 sjacqu01
58 2486 sjacqu01
  // Destroy a resolver implementation.
59 2486 sjacqu01
  BOOST_ASIO_DECL void destroy(implementation_type&);
60 2486 sjacqu01
61 2486 sjacqu01
  // Cancel pending asynchronous operations.
62 2486 sjacqu01
  BOOST_ASIO_DECL void cancel(implementation_type& impl);
63 2486 sjacqu01
64 2486 sjacqu01
protected:
65 2486 sjacqu01
  // Helper function to start an asynchronous resolve operation.
66 2486 sjacqu01
  BOOST_ASIO_DECL void start_resolve_op(operation* op);
67 2486 sjacqu01
68 2486 sjacqu01
#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
69 2486 sjacqu01
  // Helper class to perform exception-safe cleanup of addrinfo objects.
70 2486 sjacqu01
  class auto_addrinfo
71 2486 sjacqu01
    : private boost::asio::detail::noncopyable
72 2486 sjacqu01
  {
73 2486 sjacqu01
  public:
74 2486 sjacqu01
    explicit auto_addrinfo(boost::asio::detail::addrinfo_type* ai)
75 2486 sjacqu01
      : ai_(ai)
76 2486 sjacqu01
    {
77 2486 sjacqu01
    }
78 2486 sjacqu01
79 2486 sjacqu01
    ~auto_addrinfo()
80 2486 sjacqu01
    {
81 2486 sjacqu01
      if (ai_)
82 2486 sjacqu01
        socket_ops::freeaddrinfo(ai_);
83 2486 sjacqu01
    }
84 2486 sjacqu01
85 2486 sjacqu01
    operator boost::asio::detail::addrinfo_type*()
86 2486 sjacqu01
    {
87 2486 sjacqu01
      return ai_;
88 2486 sjacqu01
    }
89 2486 sjacqu01
90 2486 sjacqu01
  private:
91 2486 sjacqu01
    boost::asio::detail::addrinfo_type* ai_;
92 2486 sjacqu01
  };
93 2486 sjacqu01
#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
94 2486 sjacqu01
95 2486 sjacqu01
  // Helper class to run the work io_service in a thread.
96 2486 sjacqu01
  class work_io_service_runner;
97 2486 sjacqu01
98 2486 sjacqu01
  // Start the work thread if it's not already running.
99 2486 sjacqu01
  BOOST_ASIO_DECL void start_work_thread();
100 2486 sjacqu01
101 2486 sjacqu01
  // The io_service implementation used to post completions.
102 2486 sjacqu01
  io_service_impl& io_service_impl_;
103 2486 sjacqu01
104 2486 sjacqu01
private:
105 2486 sjacqu01
  // Mutex to protect access to internal data.
106 2486 sjacqu01
  boost::asio::detail::mutex mutex_;
107 2486 sjacqu01
108 2486 sjacqu01
  // Private io_service used for performing asynchronous host resolution.
109 2486 sjacqu01
  boost::asio::detail::scoped_ptr<boost::asio::io_service> work_io_service_;
110 2486 sjacqu01
111 2486 sjacqu01
  // The work io_service implementation used to post completions.
112 2486 sjacqu01
  io_service_impl& work_io_service_impl_;
113 2486 sjacqu01
114 2486 sjacqu01
  // Work for the private io_service to perform.
115 2486 sjacqu01
  boost::asio::detail::scoped_ptr<boost::asio::io_service::work> work_;
116 2486 sjacqu01
117 2486 sjacqu01
  // Thread used for running the work io_service's run loop.
118 2486 sjacqu01
  boost::asio::detail::scoped_ptr<boost::asio::detail::thread> work_thread_;
119 2486 sjacqu01
};
120 2486 sjacqu01
121 2486 sjacqu01
} // namespace detail
122 2486 sjacqu01
} // namespace asio
123 2486 sjacqu01
} // namespace boost
124 2486 sjacqu01
125 2486 sjacqu01
#include <boost/asio/detail/pop_options.hpp>
126 2486 sjacqu01
127 2486 sjacqu01
#if defined(BOOST_ASIO_HEADER_ONLY)
128 2486 sjacqu01
# include <boost/asio/detail/impl/resolver_service_base.ipp>
129 2486 sjacqu01
#endif // defined(BOOST_ASIO_HEADER_ONLY)
130 2486 sjacqu01
131 2486 sjacqu01
#endif // BOOST_ASIO_DETAIL_RESOLVER_SERVICE_BASE_HPP