From Jason Turner

[saferecl.hp.holder.mem]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpj77gq3an/{from.md → to.md} +75 -0
tmp/tmpj77gq3an/{from.md → to.md} RENAMED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### Member functions <a id="saferecl.hp.holder.mem">[[saferecl.hp.holder.mem]]</a>
2
+
3
+ ``` cpp
4
+ bool empty() const noexcept;
5
+ ```
6
+
7
+ *Returns:* `true` if and only if `*this` is empty.
8
+
9
+ ``` cpp
10
+ template<class T> T* protect(const atomic<T*>& src) noexcept;
11
+ ```
12
+
13
+ *Effects:* Equivalent to:
14
+
15
+ ``` cpp
16
+ T* ptr = src.load(memory_order::relaxed);
17
+ while (!try_protect(ptr, src)) {}
18
+ return ptr;
19
+ ```
20
+
21
+ ``` cpp
22
+ template<class T> bool try_protect(T*& ptr, const atomic<T*>& src) noexcept;
23
+ ```
24
+
25
+ *Mandates:* `T` is a hazard-protectable type.
26
+
27
+ *Preconditions:* `*this` is not empty.
28
+
29
+ *Effects:* Performs the following steps in order:
30
+
31
+ - Initializes a variable `old` of type `T*` with the value of `ptr`.
32
+ - Evaluates `reset_protection(old)`.
33
+ - Assigns the value of `src.load(memory_order::acquire)` to `ptr`.
34
+ - If `old == ptr` is `false`, evaluates `reset_protection()`.
35
+
36
+ *Returns:* `old == ptr`.
37
+
38
+ ``` cpp
39
+ template<class T> void reset_protection(const T* ptr) noexcept;
40
+ ```
41
+
42
+ *Mandates:* `T` is a hazard-protectable type.
43
+
44
+ *Preconditions:* `*this` is not empty.
45
+
46
+ *Effects:* If `ptr` is a null pointer value, invokes
47
+ `reset_protection()`. Otherwise, associates the hazard pointer owned by
48
+ `*this` with `*ptr`, thereby ending the current protection epoch.
49
+
50
+ *Complexity:* Constant.
51
+
52
+ ``` cpp
53
+ void reset_protection(nullptr_t = nullptr) noexcept;
54
+ ```
55
+
56
+ *Preconditions:* `*this` is not empty.
57
+
58
+ *Ensures:* The hazard pointer owned by `*this` is unassociated.
59
+
60
+ *Complexity:* Constant.
61
+
62
+ ``` cpp
63
+ void swap(hazard_pointer& other) noexcept;
64
+ ```
65
+
66
+ *Effects:* Swaps the hazard pointer ownership of this object with that
67
+ of `other`.
68
+
69
+ [*Note 1*: The owned hazard pointers, if any, remain unchanged during
70
+ the swap and continue to be associated with the respective objects that
71
+ they were protecting before the swap, if any. No protection epochs are
72
+ ended or initiated. — *end note*]
73
+
74
+ *Complexity:* Constant.
75
+