From Jason Turner

[thread.condition.condvarany.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7_fe_5q3/{from.md → to.md} +98 -0
tmp/tmp7_fe_5q3/{from.md → to.md} RENAMED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="thread.condition.condvarany.general">[[thread.condition.condvarany.general]]</a>
2
+
3
+ In this subclause [[thread.condition.condvarany]], template arguments
4
+ for template parameters named `Lock` shall meet the *Cpp17BasicLockable*
5
+ requirements [[thread.req.lockable.basic]].
6
+
7
+ [*Note 1*: All of the standard mutex types meet this requirement. If a
8
+ type other than one of the standard mutex types or a `unique_lock`
9
+ wrapper for a standard mutex type is used with `condition_variable_any`,
10
+ any necessary synchronization is assumed to be in place with respect to
11
+ the predicate associated with the `condition_variable_any`
12
+ instance. — *end note*]
13
+
14
+ ``` cpp
15
+ namespace std {
16
+ class condition_variable_any {
17
+ public:
18
+ condition_variable_any();
19
+ ~condition_variable_any();
20
+
21
+ condition_variable_any(const condition_variable_any&) = delete;
22
+ condition_variable_any& operator=(const condition_variable_any&) = delete;
23
+
24
+ void notify_one() noexcept;
25
+ void notify_all() noexcept;
26
+
27
+ // [thread.condvarany.wait], noninterruptible waits
28
+ template<class Lock>
29
+ void wait(Lock& lock);
30
+ template<class Lock, class Predicate>
31
+ void wait(Lock& lock, Predicate pred);
32
+
33
+ template<class Lock, class Clock, class Duration>
34
+ cv_status wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time);
35
+ template<class Lock, class Clock, class Duration, class Predicate>
36
+ bool wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time,
37
+ Predicate pred);
38
+ template<class Lock, class Rep, class Period>
39
+ cv_status wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time);
40
+ template<class Lock, class Rep, class Period, class Predicate>
41
+ bool wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time, Predicate pred);
42
+
43
+ // [thread.condvarany.intwait], interruptible waits
44
+ template<class Lock, class Predicate>
45
+ bool wait(Lock& lock, stop_token stoken, Predicate pred);
46
+ template<class Lock, class Clock, class Duration, class Predicate>
47
+ bool wait_until(Lock& lock, stop_token stoken,
48
+ const chrono::time_point<Clock, Duration>& abs_time, Predicate pred);
49
+ template<class Lock, class Rep, class Period, class Predicate>
50
+ bool wait_for(Lock& lock, stop_token stoken,
51
+ const chrono::duration<Rep, Period>& rel_time, Predicate pred);
52
+ };
53
+ }
54
+ ```
55
+
56
+ ``` cpp
57
+ condition_variable_any();
58
+ ```
59
+
60
+ *Throws:* `bad_alloc` or `system_error` when an exception is
61
+ required [[thread.req.exception]].
62
+
63
+ *Error conditions:*
64
+
65
+ - `resource_unavailable_try_again` — if some non-memory resource
66
+ limitation prevents initialization.
67
+ - `operation_not_permitted` — if the thread does not have the privilege
68
+ to perform the operation.
69
+
70
+ ``` cpp
71
+ ~condition_variable_any();
72
+ ```
73
+
74
+ *Preconditions:* There is no thread blocked on `*this`.
75
+
76
+ [*Note 1*: That is, all threads have been notified; they can
77
+ subsequently block on the lock specified in the wait. This relaxes the
78
+ usual rules, which would have required all wait calls to happen before
79
+ destruction. Only the notification to unblock the wait needs to happen
80
+ before destruction. Undefined behavior ensues if a thread waits on
81
+ `*this` once the destructor has been started, especially when the
82
+ waiting threads are calling the wait functions in a loop or using the
83
+ overloads of `wait`, `wait_for`, or `wait_until` that take a
84
+ predicate. — *end note*]
85
+
86
+ ``` cpp
87
+ void notify_one() noexcept;
88
+ ```
89
+
90
+ *Effects:* If any threads are blocked waiting for `*this`, unblocks one
91
+ of those threads.
92
+
93
+ ``` cpp
94
+ void notify_all() noexcept;
95
+ ```
96
+
97
+ *Effects:* Unblocks all threads that are blocked waiting for `*this`.
98
+