async_base.hpp 901 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 BOOST_BEAST_CORE_DETAIL_ASYNC_BASE_HPP
  10. #define BOOST_BEAST_CORE_DETAIL_ASYNC_BASE_HPP
  11. #include <boost/core/exchange.hpp>
  12. namespace boost {
  13. namespace beast {
  14. namespace detail {
  15. struct stable_base
  16. {
  17. static
  18. void
  19. destroy_list(stable_base*& list)
  20. {
  21. while(list)
  22. {
  23. auto next = list->next_;
  24. list->destroy();
  25. list = next;
  26. }
  27. }
  28. stable_base* next_ = nullptr;
  29. protected:
  30. stable_base() = default;
  31. virtual ~stable_base() = default;
  32. virtual void destroy() = 0;
  33. };
  34. } // detail
  35. } // beast
  36. } // boost
  37. #endif