tmp/tmp6tcmw7ng/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Non-member functions <a id="thread.condition.nonmember">[[thread.condition.nonmember]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
|
| 5 |
+
```
|
| 6 |
+
|
| 7 |
+
*Requires:* `lk` is locked by the calling thread and either
|
| 8 |
+
|
| 9 |
+
- no other thread is waiting on `cond`, or
|
| 10 |
+
- `lk.mutex()` returns the same value for each of the lock arguments
|
| 11 |
+
supplied by all concurrently waiting (via `wait`, `wait_for`, or
|
| 12 |
+
`wait_until`) threads.
|
| 13 |
+
|
| 14 |
+
*Effects:* Transfers ownership of the lock associated with `lk` into
|
| 15 |
+
internal storage and schedules `cond` to be notified when the current
|
| 16 |
+
thread exits, after all objects of thread storage duration associated
|
| 17 |
+
with the current thread have been destroyed. This notification shall be
|
| 18 |
+
as if:
|
| 19 |
+
|
| 20 |
+
``` cpp
|
| 21 |
+
lk.unlock();
|
| 22 |
+
cond.notify_all();
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
*Synchronization:* The implied `lk.unlock()` call is sequenced after the
|
| 26 |
+
destruction of all objects with thread storage duration associated with
|
| 27 |
+
the current thread.
|
| 28 |
+
|
| 29 |
+
[*Note 1*: The supplied lock will be held until the thread exits, and
|
| 30 |
+
care must be taken to ensure that this does not cause deadlock due to
|
| 31 |
+
lock ordering issues. After calling `notify_all_at_thread_exit` it is
|
| 32 |
+
recommended that the thread should be exited as soon as possible, and
|
| 33 |
+
that no blocking or time-consuming tasks are run on that
|
| 34 |
+
thread. — *end note*]
|
| 35 |
+
|
| 36 |
+
[*Note 2*: It is the user’s responsibility to ensure that waiting
|
| 37 |
+
threads do not erroneously assume that the thread has finished if they
|
| 38 |
+
experience spurious wakeups. This typically requires that the condition
|
| 39 |
+
being waited for is satisfied while holding the lock on `lk`, and that
|
| 40 |
+
this lock is not released and reacquired prior to calling
|
| 41 |
+
`notify_all_at_thread_exit`. — *end note*]
|
| 42 |
+
|