6 #ifndef XENIUM_QUIESCENT_STATE_BASED_HPP 
    7 #define XENIUM_QUIESCENT_STATE_BASED_HPP 
    9 #include <xenium/reclamation/detail/allocation_tracker.hpp> 
   10 #include <xenium/reclamation/detail/concurrent_ptr.hpp> 
   11 #include <xenium/reclamation/detail/deletable_object.hpp> 
   12 #include <xenium/reclamation/detail/guard_ptr.hpp> 
   13 #include <xenium/reclamation/detail/thread_block_list.hpp> 
   15 #include <xenium/acquire_guard.hpp> 
   17 namespace xenium::reclamation {
 
   23   template <
class T, 
class MarkedPtr>
 
   27   template <
class T, std::
size_t N = 0, 
class Deleter = std::default_delete<T>>
 
   28   class enable_concurrent_ptr;
 
   31     region_guard() noexcept;
 
   32     ~region_guard() noexcept;
 
   34     region_guard(
const region_guard&) = 
delete;
 
   35     region_guard(region_guard&&) = 
delete;
 
   36     region_guard& operator=(
const region_guard&) = 
delete;
 
   37     region_guard& operator=(region_guard&&) = 
delete;
 
   40   template <
class T, std::
size_t N = T::number_of_mark_bits>
 
   46   static constexpr 
unsigned number_epochs = 3;
 
   49   struct thread_control_block;
 
   51   inline static std::atomic<unsigned> global_epoch;
 
   52   inline static detail::thread_block_list<thread_control_block> global_thread_block_list;
 
   53   static thread_data& local_thread_data();
 
   55   ALLOCATION_TRACKING_FUNCTIONS;
 
   58 template <
class T, std::
size_t N, 
class Deleter>
 
   59 class quiescent_state_based::enable_concurrent_ptr :
 
   60     private detail::deletable_object_impl<T, Deleter>,
 
   61     private detail::tracked_object<quiescent_state_based> {
 
   63   static constexpr std::size_t number_of_mark_bits = N;
 
   66   enable_concurrent_ptr() noexcept = default;
 
   67   enable_concurrent_ptr(const enable_concurrent_ptr&) noexcept = default;
 
   68   enable_concurrent_ptr(enable_concurrent_ptr&&) noexcept = default;
 
   69   enable_concurrent_ptr& operator=(const enable_concurrent_ptr&) noexcept = default;
 
   70   enable_concurrent_ptr& operator=(enable_concurrent_ptr&&) noexcept = default;
 
   71   ~enable_concurrent_ptr() noexcept override = default;
 
   74   friend detail::deletable_object_impl<T, Deleter>;
 
   76   template <class, class>
 
   77   friend class guard_ptr;
 
   80 template <class T, class MarkedPtr>
 
   81 class 
quiescent_state_based::guard_ptr : public detail::guard_ptr<T, MarkedPtr, guard_ptr<T, MarkedPtr>> {
 
   82   using base = detail::guard_ptr<T, MarkedPtr, guard_ptr>;
 
   83   using Deleter = 
typename T::Deleter;
 
   87   explicit guard_ptr(
const MarkedPtr& p = MarkedPtr()) noexcept;
 
   88   guard_ptr(const guard_ptr& p) noexcept;
 
   89   guard_ptr(guard_ptr&& p) noexcept;
 
   91   guard_ptr& operator=(const guard_ptr& p) noexcept;
 
   92   guard_ptr& operator=(guard_ptr&& p) noexcept;
 
   95   void acquire(const concurrent_ptr<T>& p, std::memory_order order = std::memory_order_seq_cst) noexcept;
 
   98   bool acquire_if_equal(const concurrent_ptr<T>& p,
 
   99                         const MarkedPtr& expected,
 
  100                         std::memory_order order = std::memory_order_seq_cst) noexcept;
 
  103   void reset() noexcept;
 
  106   void reclaim(Deleter d = Deleter()) noexcept;
 
  110 #define QUIESCENT_STATE_BASED_IMPL 
  111 #include <xenium/reclamation/impl/quiescent_state_based.hpp> 
  112 #undef QUIESCENT_STATE_BASED_IMPL