]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/example/cpp03/http/server2/io_service_pool.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / asio / example / cpp03 / http / server2 / io_service_pool.hpp
CommitLineData
7c673cae
FG
1//
2// io_service_pool.hpp
3// ~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2016 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 HTTP_SERVER2_IO_SERVICE_POOL_HPP
12#define HTTP_SERVER2_IO_SERVICE_POOL_HPP
13
14#include <boost/asio.hpp>
15#include <vector>
16#include <boost/noncopyable.hpp>
17#include <boost/shared_ptr.hpp>
18
19namespace http {
20namespace server2 {
21
22/// A pool of io_service objects.
23class io_service_pool
24 : private boost::noncopyable
25{
26public:
27 /// Construct the io_service pool.
28 explicit io_service_pool(std::size_t pool_size);
29
30 /// Run all io_service objects in the pool.
31 void run();
32
33 /// Stop all io_service objects in the pool.
34 void stop();
35
36 /// Get an io_service to use.
37 boost::asio::io_service& get_io_service();
38
39private:
40 typedef boost::shared_ptr<boost::asio::io_service> io_service_ptr;
41 typedef boost::shared_ptr<boost::asio::io_service::work> work_ptr;
42
43 /// The pool of io_services.
44 std::vector<io_service_ptr> io_services_;
45
46 /// The work that keeps the io_services running.
47 std::vector<work_ptr> work_;
48
49 /// The next io_service to use for a connection.
50 std::size_t next_io_service_;
51};
52
53} // namespace server2
54} // namespace http
55
56#endif // HTTP_SERVER2_IO_SERVICE_POOL_HPP