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