execution_context.ipp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // impl/execution_context.ipp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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. #ifndef BOOST_ASIO_IMPL_EXECUTION_CONTEXT_IPP
  11. #define BOOST_ASIO_IMPL_EXECUTION_CONTEXT_IPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/execution_context.hpp>
  17. #include <boost/asio/detail/service_registry.hpp>
  18. #include <boost/asio/detail/push_options.hpp>
  19. namespace boost {
  20. namespace asio {
  21. execution_context::execution_context()
  22. : service_registry_(new boost::asio::detail::service_registry(*this))
  23. {
  24. }
  25. execution_context::~execution_context()
  26. {
  27. shutdown();
  28. destroy();
  29. delete service_registry_;
  30. }
  31. void execution_context::shutdown()
  32. {
  33. service_registry_->shutdown_services();
  34. }
  35. void execution_context::destroy()
  36. {
  37. service_registry_->destroy_services();
  38. }
  39. void execution_context::notify_fork(
  40. boost::asio::execution_context::fork_event event)
  41. {
  42. service_registry_->notify_fork(event);
  43. }
  44. execution_context::service::service(execution_context& owner)
  45. : owner_(owner),
  46. next_(0)
  47. {
  48. }
  49. execution_context::service::~service()
  50. {
  51. }
  52. void execution_context::service::notify_fork(execution_context::fork_event)
  53. {
  54. }
  55. service_already_exists::service_already_exists()
  56. : std::logic_error("Service already exists.")
  57. {
  58. }
  59. invalid_service_owner::invalid_service_owner()
  60. : std::logic_error("Invalid service owner.")
  61. {
  62. }
  63. } // namespace asio
  64. } // namespace boost
  65. #include <boost/asio/detail/pop_options.hpp>
  66. #endif // BOOST_ASIO_IMPL_EXECUTION_CONTEXT_IPP