tmp/tmpevtx7zh8/{from.md → to.md}
RENAMED
|
@@ -7,33 +7,35 @@ namespace std {
|
|
| 7 |
|
| 8 |
static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic type's operations are always lock free;
|
| 9 |
bool is_lock_free() const noexcept;
|
| 10 |
|
| 11 |
constexpr atomic() noexcept;
|
| 12 |
-
atomic(weak_ptr<T> desired) noexcept;
|
| 13 |
atomic(const atomic&) = delete;
|
| 14 |
void operator=(const atomic&) = delete;
|
| 15 |
|
| 16 |
-
weak_ptr<T> load(memory_order order = memory_order::seq_cst) const noexcept;
|
| 17 |
-
operator weak_ptr<T>() const noexcept;
|
| 18 |
-
void store(weak_ptr<T> desired,
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
weak_ptr<T> exchange(weak_ptr<T> desired,
|
| 22 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 23 |
-
bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 24 |
memory_order success, memory_order failure) noexcept;
|
| 25 |
-
bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 26 |
memory_order success, memory_order failure) noexcept;
|
| 27 |
-
bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 28 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 29 |
-
bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 30 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 31 |
|
| 32 |
-
void wait(weak_ptr<T> old,
|
| 33 |
-
|
| 34 |
-
void
|
|
|
|
| 35 |
|
| 36 |
private:
|
| 37 |
weak_ptr<T> p; // exposition only
|
| 38 |
};
|
| 39 |
}
|
|
@@ -41,14 +43,14 @@ namespace std {
|
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
constexpr atomic() noexcept;
|
| 44 |
```
|
| 45 |
|
| 46 |
-
*Effects:*
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
-
atomic(weak_ptr<T> desired) noexcept;
|
| 50 |
```
|
| 51 |
|
| 52 |
*Effects:* Initializes the object with the value `desired`.
|
| 53 |
Initialization is not an atomic operation [[intro.multithread]].
|
| 54 |
|
|
@@ -58,63 +60,64 @@ the just-constructed object `A` to another thread via
|
|
| 58 |
`memory_order::relaxed` operations on a suitable atomic pointer
|
| 59 |
variable, and then immediately accessing `A` in the receiving thread.
|
| 60 |
This results in undefined behavior. — *end note*]
|
| 61 |
|
| 62 |
``` cpp
|
| 63 |
-
void store(weak_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept;
|
| 64 |
```
|
| 65 |
|
| 66 |
-
*Preconditions:* `order` is
|
| 67 |
-
`memory_order::
|
| 68 |
|
| 69 |
*Effects:* Atomically replaces the value pointed to by `this` with the
|
| 70 |
value of `desired` as if by `p.swap(desired)`. Memory is affected
|
| 71 |
according to the value of `order`.
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
-
void operator=(weak_ptr<T> desired) noexcept;
|
| 75 |
```
|
| 76 |
|
| 77 |
*Effects:* Equivalent to `store(desired)`.
|
| 78 |
|
| 79 |
``` cpp
|
| 80 |
-
weak_ptr<T> load(memory_order order = memory_order::seq_cst) const noexcept;
|
| 81 |
```
|
| 82 |
|
| 83 |
-
*Preconditions:* `order` is
|
| 84 |
-
`memory_order::
|
| 85 |
|
| 86 |
*Effects:* Memory is affected according to the value of `order`.
|
| 87 |
|
| 88 |
*Returns:* Atomically returns `p`.
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
-
operator weak_ptr<T>() const noexcept;
|
| 92 |
```
|
| 93 |
|
| 94 |
*Effects:* Equivalent to: `return load();`
|
| 95 |
|
| 96 |
``` cpp
|
| 97 |
-
weak_ptr<T> exchange(weak_ptr<T> desired,
|
|
|
|
| 98 |
```
|
| 99 |
|
| 100 |
*Effects:* Atomically replaces `p` with `desired` as if by
|
| 101 |
`p.swap(desired)`. Memory is affected according to the value of `order`.
|
| 102 |
This is an atomic read-modify-write operation [[intro.races]].
|
| 103 |
|
| 104 |
*Returns:* Atomically returns the value of `p` immediately before the
|
| 105 |
effects.
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
-
bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 109 |
memory_order success, memory_order failure) noexcept;
|
| 110 |
-
bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 111 |
memory_order success, memory_order failure) noexcept;
|
| 112 |
```
|
| 113 |
|
| 114 |
-
*Preconditions:* `failure` is
|
| 115 |
-
`memory_order::
|
| 116 |
|
| 117 |
*Effects:* If `p` is equivalent to `expected`, assigns `desired` to `p`
|
| 118 |
and has synchronization semantics corresponding to the value of
|
| 119 |
`success`, otherwise assigns `p` to `expected` and has synchronization
|
| 120 |
semantics corresponding to the value of `failure`.
|
|
@@ -135,11 +138,11 @@ object in the attempted atomic update. The `use_count` update
|
|
| 135 |
corresponding to the write to `expected` is part of the atomic
|
| 136 |
operation. The write to `expected` itself is not required to be part of
|
| 137 |
the atomic operation.
|
| 138 |
|
| 139 |
``` cpp
|
| 140 |
-
bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 141 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 142 |
```
|
| 143 |
|
| 144 |
*Effects:* Equivalent to:
|
| 145 |
|
|
@@ -151,11 +154,11 @@ where `fail_order` is the same as `order` except that a value of
|
|
| 151 |
`memory_order::acq_rel` shall be replaced by the value
|
| 152 |
`memory_order::acquire` and a value of `memory_order::release` shall be
|
| 153 |
replaced by the value `memory_order::relaxed`.
|
| 154 |
|
| 155 |
``` cpp
|
| 156 |
-
bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 157 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 158 |
```
|
| 159 |
|
| 160 |
*Effects:* Equivalent to:
|
| 161 |
|
|
@@ -167,15 +170,15 @@ where `fail_order` is the same as `order` except that a value of
|
|
| 167 |
`memory_order::acq_rel` shall be replaced by the value
|
| 168 |
`memory_order::acquire` and a value of `memory_order::release` shall be
|
| 169 |
replaced by the value `memory_order::relaxed`.
|
| 170 |
|
| 171 |
``` cpp
|
| 172 |
-
void wait(weak_ptr<T> old, memory_order order = memory_order::seq_cst) const noexcept;
|
| 173 |
```
|
| 174 |
|
| 175 |
-
*Preconditions:* `order` is
|
| 176 |
-
`memory_order::
|
| 177 |
|
| 178 |
*Effects:* Repeatedly performs the following steps, in order:
|
| 179 |
|
| 180 |
- Evaluates `load(order)` and compares it to `old`.
|
| 181 |
- If the two are not equivalent, returns.
|
|
@@ -185,22 +188,22 @@ void wait(weak_ptr<T> old, memory_order order = memory_order::seq_cst) const noe
|
|
| 185 |
*Remarks:* Two `weak_ptr` objects are equivalent if they store the same
|
| 186 |
pointer and either share ownership or are both empty. This function is
|
| 187 |
an atomic waiting operation [[atomics.wait]].
|
| 188 |
|
| 189 |
``` cpp
|
| 190 |
-
void notify_one() noexcept;
|
| 191 |
```
|
| 192 |
|
| 193 |
*Effects:* Unblocks the execution of at least one atomic waiting
|
| 194 |
operation that is eligible to be unblocked [[atomics.wait]] by this
|
| 195 |
call, if any such atomic waiting operations exist.
|
| 196 |
|
| 197 |
*Remarks:* This function is an atomic notifying
|
| 198 |
operation [[atomics.wait]].
|
| 199 |
|
| 200 |
``` cpp
|
| 201 |
-
void notify_all() noexcept;
|
| 202 |
```
|
| 203 |
|
| 204 |
*Effects:* Unblocks the execution of all atomic waiting operations that
|
| 205 |
are eligible to be unblocked [[atomics.wait]] by this call.
|
| 206 |
|
|
|
|
| 7 |
|
| 8 |
static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic type's operations are always lock free;
|
| 9 |
bool is_lock_free() const noexcept;
|
| 10 |
|
| 11 |
constexpr atomic() noexcept;
|
| 12 |
+
constexpr atomic(weak_ptr<T> desired) noexcept;
|
| 13 |
atomic(const atomic&) = delete;
|
| 14 |
void operator=(const atomic&) = delete;
|
| 15 |
|
| 16 |
+
constexpr weak_ptr<T> load(memory_order order = memory_order::seq_cst) const noexcept;
|
| 17 |
+
constexpr operator weak_ptr<T>() const noexcept;
|
| 18 |
+
constexpr void store(weak_ptr<T> desired,
|
| 19 |
+
memory_order order = memory_order::seq_cst) noexcept;
|
| 20 |
+
constexpr void operator=(weak_ptr<T> desired) noexcept;
|
| 21 |
|
| 22 |
+
constexpr weak_ptr<T> exchange(weak_ptr<T> desired,
|
| 23 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 24 |
+
constexpr bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 25 |
memory_order success, memory_order failure) noexcept;
|
| 26 |
+
constexpr bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 27 |
memory_order success, memory_order failure) noexcept;
|
| 28 |
+
constexpr bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 29 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 30 |
+
constexpr bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 31 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 32 |
|
| 33 |
+
constexpr void wait(weak_ptr<T> old,
|
| 34 |
+
memory_order order = memory_order::seq_cst) const noexcept;
|
| 35 |
+
constexpr void notify_one() noexcept;
|
| 36 |
+
constexpr void notify_all() noexcept;
|
| 37 |
|
| 38 |
private:
|
| 39 |
weak_ptr<T> p; // exposition only
|
| 40 |
};
|
| 41 |
}
|
|
|
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
constexpr atomic() noexcept;
|
| 46 |
```
|
| 47 |
|
| 48 |
+
*Effects:* Value-initializes `p`.
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
+
constexpr atomic(weak_ptr<T> desired) noexcept;
|
| 52 |
```
|
| 53 |
|
| 54 |
*Effects:* Initializes the object with the value `desired`.
|
| 55 |
Initialization is not an atomic operation [[intro.multithread]].
|
| 56 |
|
|
|
|
| 60 |
`memory_order::relaxed` operations on a suitable atomic pointer
|
| 61 |
variable, and then immediately accessing `A` in the receiving thread.
|
| 62 |
This results in undefined behavior. — *end note*]
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
+
constexpr void store(weak_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept;
|
| 66 |
```
|
| 67 |
|
| 68 |
+
*Preconditions:* `order` is `memory_order::relaxed`,
|
| 69 |
+
`memory_order::release`, or `memory_order::seq_cst`.
|
| 70 |
|
| 71 |
*Effects:* Atomically replaces the value pointed to by `this` with the
|
| 72 |
value of `desired` as if by `p.swap(desired)`. Memory is affected
|
| 73 |
according to the value of `order`.
|
| 74 |
|
| 75 |
``` cpp
|
| 76 |
+
constexpr void operator=(weak_ptr<T> desired) noexcept;
|
| 77 |
```
|
| 78 |
|
| 79 |
*Effects:* Equivalent to `store(desired)`.
|
| 80 |
|
| 81 |
``` cpp
|
| 82 |
+
constexpr weak_ptr<T> load(memory_order order = memory_order::seq_cst) const noexcept;
|
| 83 |
```
|
| 84 |
|
| 85 |
+
*Preconditions:* `order` is `memory_order::relaxed`,
|
| 86 |
+
`memory_order::acquire`, or `memory_order::seq_cst`.
|
| 87 |
|
| 88 |
*Effects:* Memory is affected according to the value of `order`.
|
| 89 |
|
| 90 |
*Returns:* Atomically returns `p`.
|
| 91 |
|
| 92 |
``` cpp
|
| 93 |
+
constexpr operator weak_ptr<T>() const noexcept;
|
| 94 |
```
|
| 95 |
|
| 96 |
*Effects:* Equivalent to: `return load();`
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
+
constexpr weak_ptr<T> exchange(weak_ptr<T> desired,
|
| 100 |
+
memory_order order = memory_order::seq_cst) noexcept;
|
| 101 |
```
|
| 102 |
|
| 103 |
*Effects:* Atomically replaces `p` with `desired` as if by
|
| 104 |
`p.swap(desired)`. Memory is affected according to the value of `order`.
|
| 105 |
This is an atomic read-modify-write operation [[intro.races]].
|
| 106 |
|
| 107 |
*Returns:* Atomically returns the value of `p` immediately before the
|
| 108 |
effects.
|
| 109 |
|
| 110 |
``` cpp
|
| 111 |
+
constexpr bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 112 |
memory_order success, memory_order failure) noexcept;
|
| 113 |
+
constexpr bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 114 |
memory_order success, memory_order failure) noexcept;
|
| 115 |
```
|
| 116 |
|
| 117 |
+
*Preconditions:* `failure` is `memory_order::relaxed`,
|
| 118 |
+
`memory_order::acquire`, or `memory_order::seq_cst`.
|
| 119 |
|
| 120 |
*Effects:* If `p` is equivalent to `expected`, assigns `desired` to `p`
|
| 121 |
and has synchronization semantics corresponding to the value of
|
| 122 |
`success`, otherwise assigns `p` to `expected` and has synchronization
|
| 123 |
semantics corresponding to the value of `failure`.
|
|
|
|
| 138 |
corresponding to the write to `expected` is part of the atomic
|
| 139 |
operation. The write to `expected` itself is not required to be part of
|
| 140 |
the atomic operation.
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
+
constexpr bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 144 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 145 |
```
|
| 146 |
|
| 147 |
*Effects:* Equivalent to:
|
| 148 |
|
|
|
|
| 154 |
`memory_order::acq_rel` shall be replaced by the value
|
| 155 |
`memory_order::acquire` and a value of `memory_order::release` shall be
|
| 156 |
replaced by the value `memory_order::relaxed`.
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
+
constexpr bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
|
| 160 |
memory_order order = memory_order::seq_cst) noexcept;
|
| 161 |
```
|
| 162 |
|
| 163 |
*Effects:* Equivalent to:
|
| 164 |
|
|
|
|
| 170 |
`memory_order::acq_rel` shall be replaced by the value
|
| 171 |
`memory_order::acquire` and a value of `memory_order::release` shall be
|
| 172 |
replaced by the value `memory_order::relaxed`.
|
| 173 |
|
| 174 |
``` cpp
|
| 175 |
+
constexpr void wait(weak_ptr<T> old, memory_order order = memory_order::seq_cst) const noexcept;
|
| 176 |
```
|
| 177 |
|
| 178 |
+
*Preconditions:* `order` is `memory_order::relaxed`,
|
| 179 |
+
`memory_order::acquire`, or `memory_order::seq_cst`.
|
| 180 |
|
| 181 |
*Effects:* Repeatedly performs the following steps, in order:
|
| 182 |
|
| 183 |
- Evaluates `load(order)` and compares it to `old`.
|
| 184 |
- If the two are not equivalent, returns.
|
|
|
|
| 188 |
*Remarks:* Two `weak_ptr` objects are equivalent if they store the same
|
| 189 |
pointer and either share ownership or are both empty. This function is
|
| 190 |
an atomic waiting operation [[atomics.wait]].
|
| 191 |
|
| 192 |
``` cpp
|
| 193 |
+
constexpr void notify_one() noexcept;
|
| 194 |
```
|
| 195 |
|
| 196 |
*Effects:* Unblocks the execution of at least one atomic waiting
|
| 197 |
operation that is eligible to be unblocked [[atomics.wait]] by this
|
| 198 |
call, if any such atomic waiting operations exist.
|
| 199 |
|
| 200 |
*Remarks:* This function is an atomic notifying
|
| 201 |
operation [[atomics.wait]].
|
| 202 |
|
| 203 |
``` cpp
|
| 204 |
+
constexpr void notify_all() noexcept;
|
| 205 |
```
|
| 206 |
|
| 207 |
*Effects:* Unblocks the execution of all atomic waiting operations that
|
| 208 |
are eligible to be unblocked [[atomics.wait]] by this call.
|
| 209 |
|