xenium
orphan.hpp
1 //
2 // Copyright (c) 2018-2020 Manuel Pöter.
3 // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 //
5 
6 #ifndef XENIUM_DETAIL_ORPHAN_HPP
7 #define XENIUM_DETAIL_ORPHAN_HPP
8 
9 #include <array>
10 #include <xenium/reclamation/detail/deletable_object.hpp>
11 
12 namespace xenium::reclamation::detail {
13 
14 template <unsigned Epochs>
15 struct orphan : detail::deletable_object_impl<orphan<Epochs>> {
16  orphan(unsigned target_epoch, std::array<detail::deletable_object*, Epochs>& retire_lists) :
17  target_epoch(target_epoch),
18  retire_lists(retire_lists) {}
19 
20  ~orphan() override {
21  for (auto p : retire_lists) {
22  detail::delete_objects(p);
23  }
24  }
25 
26  const unsigned target_epoch;
27 
28 private:
29  std::array<detail::deletable_object*, Epochs> retire_lists;
30 };
31 
32 } // namespace xenium::reclamation::detail
33 
34 #endif