service.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail 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. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BHO_BEAST_WEBSOCKET_DETAIL_SERVICE_HPP
  10. #define BHO_BEAST_WEBSOCKET_DETAIL_SERVICE_HPP
  11. #include <asio2/bho/beast/core/detail/service_base.hpp>
  12. #include <asio/execution_context.hpp>
  13. #include <mutex>
  14. #include <vector>
  15. namespace bho {
  16. namespace beast {
  17. namespace websocket {
  18. namespace detail {
  19. class service
  20. : public beast::detail::service_base<service>
  21. {
  22. public:
  23. class impl_type
  24. : public std::enable_shared_from_this<impl_type>
  25. {
  26. service& svc_;
  27. std::size_t index_;
  28. friend class service;
  29. public:
  30. virtual ~impl_type() = default;
  31. BHO_BEAST_DECL
  32. explicit
  33. impl_type(net::execution_context& ctx);
  34. BHO_BEAST_DECL
  35. void
  36. remove();
  37. virtual
  38. void
  39. shutdown() = 0;
  40. };
  41. private:
  42. std::mutex m_;
  43. std::vector<impl_type*> v_;
  44. BHO_BEAST_DECL
  45. void
  46. shutdown() override;
  47. public:
  48. BHO_BEAST_DECL
  49. explicit
  50. service(net::execution_context& ctx)
  51. : beast::detail::service_base<service>(ctx)
  52. {
  53. }
  54. };
  55. } // detail
  56. } // websocket
  57. } // beast
  58. } // bho
  59. #if BEAST_HEADER_ONLY
  60. #include <asio2/bho/beast/websocket/detail/service.ipp>
  61. #endif
  62. #endif