Imported Upstream version 1.49.0
[platform/upstream/boost.git] / libs / asio / doc / requirements / Service.qbk
1 [/
2  / Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
3  /
4  / Distributed under the Boost Software License, Version 1.0. (See accompanying
5  / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  /]
7
8 [section:Service Service requirements]
9
10 A class is a service if it is publicly derived from another service, or if it
11 is a class derived from `io_service::service` and contains a
12 publicly-accessible declaration as follows:
13
14   static io_service::id id;
15
16 All services define a one-argument constructor that takes a reference to the
17 `io_service` object that owns the service. This constructor is /explicit/,
18 preventing its participation in automatic conversions. For example:
19
20   class my_service : public io_service::service
21   {
22   public:
23     static io_service::id id;
24     explicit my_service(io_service& ios);
25   private:
26     virtual void shutdown_service();
27     ...
28   };
29
30 A service's `shutdown_service` member function must cause all copies of
31 user-defined handler objects that are held by the service to be destroyed.
32
33 [endsect]