Service.qbk 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. [/
  2. / Copyright (c) 2003-2019 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. [section:Service Service requirements]
  8. A class is a ['service] if it is publicly and unambiguously derived from
  9. `execution_context::service`, or if it is publicly and unambiguously derived
  10. from another service. For a service `S`, `S::key_type` shall be valid and
  11. denote a type (C++Std [temp.deduct]), `is_base_of_v<typename S::key_type, S>`
  12. shall be `true`, and `S` shall satisfy the `Destructible` requirements (C++Std
  13. [destructible]).
  14. The first parameter of all service constructors shall be an lvalue reference to
  15. `execution_context`. This parameter denotes the `execution_context` object that
  16. represents a set of services, of which the service object will be a member.
  17. [inline_note These constructors may be called by the `make_service` function.]
  18. A service shall provide an explicit constructor with a single parameter of
  19. lvalue reference to `execution_context`. [inline_note This constructor may be
  20. called by the `use_service` function.]
  21. class my_service : public execution_context::service
  22. {
  23. public:
  24. typedef my_service key_type;
  25. explicit my_service(execution_context& ctx);
  26. my_service(execution_context& ctx, int some_value);
  27. private:
  28. virtual void shutdown() noexcept override;
  29. ...
  30. };
  31. A service's `shutdown` member function shall destroy all copies of user-defined
  32. function objects that are held by the service.
  33. [endsect]