cycle_ptr
vertex.h
1 #ifndef CYCLE_PTR_DETAIL_VERTEX_H
2 #define CYCLE_PTR_DETAIL_VERTEX_H
3 
4 #include <cycle_ptr/detail/intrusive_ptr.h>
5 #include <cycle_ptr/detail/llist.h>
6 #include <cycle_ptr/detail/hazard.h>
7 
8 namespace cycle_ptr::detail {
9 
10 
11 class base_control;
12 class generation;
13 
14 class vertex
15 : public link<vertex>
16 {
17  friend class generation;
18  friend class base_control;
19 
20  protected:
21  vertex();
22 
23  vertex([[maybe_unused]] const vertex& other)
24  : vertex()
25  {}
26 
27  explicit vertex(intrusive_ptr<base_control> bc) noexcept;
28  ~vertex() noexcept;
29 
30  auto reset() -> void;
31 
44  auto reset(
46  bool has_reference,
47  bool no_red_promotion)
48  -> void;
49 
51  auto owner_is_expired() const noexcept -> bool;
52 
58  -> void {
59  if (owner_is_expired()) throw std::bad_weak_ptr();
60  }
61 
62  public:
65  auto get_control() const noexcept -> intrusive_ptr<base_control>;
66 
67  private:
68  const intrusive_ptr<base_control> bc_; // Non-null.
70 };
71 
72 
73 } /* namespace cycle_ptr::detail */
74 
75 #endif /* CYCLE_PTR_DETAIL_VERTEX_H */
Definition: generation.h:19
auto throw_if_owner_expired() const -> void
Throw exception if owner is expired.
Definition: vertex.h:57
Intrusive pointer.
Definition: intrusive_ptr.h:21
Hazard pointer.
Definition: hazard.h:413
auto owner_is_expired() const noexcept -> bool
Test if origin is expired.
Definition: vertex.h:14
auto get_control() const noexcept -> intrusive_ptr< base_control >
Read the target control block.
Base class for all control blocks.
Definition: base_control.h:30