cycle_ptr
util.h
Go to the documentation of this file.
1 #ifndef CYCLE_PTR_UTIL_H
2 #define CYCLE_PTR_UTIL_H
3 
6 
7 #include <functional>
8 #include <cycle_ptr/detail/intrusive_ptr.h>
9 #include <cycle_ptr/detail/generation.h>
10 
11 namespace cycle_ptr {
12 
13 
24 class gc_operation {
25  public:
27  constexpr gc_operation() noexcept = default;
28 
31  : g_(std::move(g))
32  {}
33 
36  auto operator()()
37  noexcept
38  -> void {
39  if (g_ != nullptr) g_->gc_();
40  g_.reset();
41  }
42 
43  private:
46 };
47 
71 using delay_gc = std::function<void(gc_operation)>;
72 
84 auto get_delay_gc() -> delay_gc;
85 
113 auto set_delay_gc(delay_gc f) -> delay_gc;
114 
115 
116 } /* namespace cycle_ptr */
117 
118 #endif /* CYCLE_PTR_UTIL_H */
std::function< void(gc_operation)> delay_gc
Function for delayed GC invocations.
Definition: util.h:71
gc_operation(detail::intrusive_ptr< detail::generation > g) noexcept
Constructor for internal use.
Definition: util.h:30
Intrusive pointer.
Definition: intrusive_ptr.h:21
GC operations for delayed collection.
Definition: util.h:24
constexpr gc_operation() noexcept=default
Default constructor performs no collections.
auto operator()() noexcept -> void
Run the GC.
Definition: util.h:36