From Jason Turner

[thread.timedmutex.requirements]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxk2bmx1u/{from.md → to.md} +41 -41
tmp/tmpxk2bmx1u/{from.md → to.md} RENAMED
@@ -1,55 +1,55 @@
1
  #### Timed mutex types <a id="thread.timedmutex.requirements">[[thread.timedmutex.requirements]]</a>
2
 
3
  The *timed mutex types* are the standard library types `timed_mutex`,
4
- `recursive_timed_mutex`, and `shared_timed_mutex`. They shall meet the
5
  requirements set out below. In this description, `m` denotes an object
6
  of a mutex type, `rel_time` denotes an object of an instantiation of
7
- `duration` ([[time.duration]]), and `abs_time` denotes an object of an
8
- instantiation of `time_point` ([[time.point]]).
9
 
10
- The timed mutex types shall meet the `TimedLockable` requirements (
11
- [[thread.req.lockable.timed]]).
12
 
13
- The expression `m.try_lock_for(rel_time)` shall be well-formed and have
14
- the following semantics:
15
 
16
- *Requires:* If `m` is of type `timed_mutex` or `shared_timed_mutex`, the
17
- calling thread does not own the mutex.
18
 
19
  *Effects:* The function attempts to obtain ownership of the mutex within
20
- the relative timeout ([[thread.req.timing]]) specified by `rel_time`.
21
- If the time specified by `rel_time` is less than or equal to
22
  `rel_time.zero()`, the function attempts to obtain ownership without
23
- blocking (as if by calling `try_lock()`). The function shall return
24
- within the timeout specified by `rel_time` only if it has obtained
25
- ownership of the mutex object.
26
 
27
  [*Note 1*: As with `try_lock()`, there is no guarantee that ownership
28
  will be obtained if the lock is available, but implementations are
29
  expected to make a strong effort to do so. — *end note*]
30
 
31
  *Return type:* `bool`.
32
 
33
  *Returns:* `true` if ownership was obtained, otherwise `false`.
34
 
35
  *Synchronization:* If `try_lock_for()` returns `true`, prior `unlock()`
36
- operations on the same object *synchronize
37
- with* ([[intro.multithread]]) this operation.
38
 
39
- *Throws:* Timeout-related exceptions ([[thread.req.timing]]).
40
 
41
- The expression `m.try_lock_until(abs_time)` shall be well-formed and
42
- have the following semantics:
43
 
44
- *Requires:* If `m` is of type `timed_mutex` or `shared_timed_mutex`, the
45
- calling thread does not own the mutex.
46
 
47
  *Effects:* The function attempts to obtain ownership of the mutex. If
48
  `abs_time` has already passed, the function attempts to obtain ownership
49
- without blocking (as if by calling `try_lock()`). The function shall
50
- return before the absolute timeout ([[thread.req.timing]]) specified by
51
  `abs_time` only if it has obtained ownership of the mutex object.
52
 
53
  [*Note 2*: As with `try_lock()`, there is no guarantee that ownership
54
  will be obtained if the lock is available, but implementations are
55
  expected to make a strong effort to do so. — *end note*]
@@ -58,13 +58,13 @@ expected to make a strong effort to do so. — *end note*]
58
 
59
  *Returns:* `true` if ownership was obtained, otherwise `false`.
60
 
61
  *Synchronization:* If `try_lock_until()` returns `true`, prior
62
  `unlock()` operations on the same object *synchronize
63
- with* ([[intro.multithread]]) this operation.
64
 
65
- *Throws:* Timeout-related exceptions ([[thread.req.timing]]).
66
 
67
  ##### Class `timed_mutex` <a id="thread.timedmutex.class">[[thread.timedmutex.class]]</a>
68
 
69
  ``` cpp
70
  namespace std {
@@ -82,12 +82,12 @@ namespace std {
82
  bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
83
  template<class Clock, class Duration>
84
  bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
85
  void unlock();
86
 
87
- using native_handle_type = implementation-defined; // See~[thread.req.native]
88
- native_handle_type native_handle(); // See~[thread.req.native]
89
  };
90
  }
91
  ```
92
 
93
  The class `timed_mutex` provides a non-recursive mutex with exclusive
@@ -96,13 +96,13 @@ by another thread to acquire ownership of that object will fail (for
96
  `try_lock()`) or block (for `lock()`, `try_lock_for()`, and
97
  `try_lock_until()`) until the owning thread has released ownership with
98
  a call to `unlock()` or the call to `try_lock_for()` or
99
  `try_lock_until()` times out (having failed to obtain ownership).
100
 
101
- The class `timed_mutex` shall satisfy all of the timed mutex
102
- requirements ([[thread.timedmutex.requirements]]). It shall be a
103
- standard-layout class (Clause  [[class]]).
104
 
105
  The behavior of a program is undefined if:
106
 
107
  - it destroys a `timed_mutex` object owned by any thread,
108
  - a thread that owns a `timed_mutex` object calls `lock()`,
@@ -128,12 +128,12 @@ namespace std {
128
  bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
129
  template<class Clock, class Duration>
130
  bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
131
  void unlock();
132
 
133
- using native_handle_type = implementation-defined; // See~[thread.req.native]
134
- native_handle_type native_handle(); // See~[thread.req.native]
135
  };
136
  }
137
  ```
138
 
139
  The class `recursive_timed_mutex` provides a recursive mutex with
@@ -142,26 +142,26 @@ exclusive ownership semantics. If one thread owns a
142
  ownership of that object will fail (for `try_lock()`) or block (for
143
  `lock()`, `try_lock_for()`, and `try_lock_until()`) until the owning
144
  thread has completely released ownership or the call to `try_lock_for()`
145
  or `try_lock_until()` times out (having failed to obtain ownership).
146
 
147
- The class `recursive_timed_mutex` shall satisfy all of the timed mutex
148
- requirements ([[thread.timedmutex.requirements]]). It shall be a
149
- standard-layout class (Clause  [[class]]).
150
 
151
  A thread that owns a `recursive_timed_mutex` object may acquire
152
  additional levels of ownership by calling `lock()`, `try_lock()`,
153
  `try_lock_for()`, or `try_lock_until()` on that object. It is
154
  unspecified how many levels of ownership may be acquired by a single
155
  thread. If a thread has already acquired the maximum level of ownership
156
  for a `recursive_timed_mutex` object, additional calls to `try_lock()`,
157
- `try_lock_for()`, or `try_lock_until()` shall fail, and additional calls
158
- to `lock()` shall throw an exception of type `system_error`. A thread
159
- shall call `unlock()` once for each level of ownership acquired by calls
160
- to `lock()`, `try_lock()`, `try_lock_for()`, and `try_lock_until()`.
161
- Only when all levels of ownership have been released may ownership of
162
- the object be acquired by another thread.
163
 
164
  The behavior of a program is undefined if:
165
 
166
  - it destroys a `recursive_timed_mutex` object owned by any thread, or
167
  - a thread terminates while owning a `recursive_timed_mutex` object.
 
1
  #### Timed mutex types <a id="thread.timedmutex.requirements">[[thread.timedmutex.requirements]]</a>
2
 
3
  The *timed mutex types* are the standard library types `timed_mutex`,
4
+ `recursive_timed_mutex`, and `shared_timed_mutex`. They meet the
5
  requirements set out below. In this description, `m` denotes an object
6
  of a mutex type, `rel_time` denotes an object of an instantiation of
7
+ `duration` [[time.duration]], and `abs_time` denotes an object of an
8
+ instantiation of `time_point` [[time.point]].
9
 
10
+ The timed mutex types meet the *Cpp17TimedLockable* requirements
11
+ [[thread.req.lockable.timed]].
12
 
13
+ The expression `m.try_lock_for(rel_time)` is well-formed and has the
14
+ following semantics:
15
 
16
+ *Preconditions:* If `m` is of type `timed_mutex` or
17
+ `shared_timed_mutex`, the calling thread does not own the mutex.
18
 
19
  *Effects:* The function attempts to obtain ownership of the mutex within
20
+ the relative timeout [[thread.req.timing]] specified by `rel_time`. If
21
+ the time specified by `rel_time` is less than or equal to
22
  `rel_time.zero()`, the function attempts to obtain ownership without
23
+ blocking (as if by calling `try_lock()`). The function returns within
24
+ the timeout specified by `rel_time` only if it has obtained ownership of
25
+ the mutex object.
26
 
27
  [*Note 1*: As with `try_lock()`, there is no guarantee that ownership
28
  will be obtained if the lock is available, but implementations are
29
  expected to make a strong effort to do so. — *end note*]
30
 
31
  *Return type:* `bool`.
32
 
33
  *Returns:* `true` if ownership was obtained, otherwise `false`.
34
 
35
  *Synchronization:* If `try_lock_for()` returns `true`, prior `unlock()`
36
+ operations on the same object *synchronize with*[[intro.multithread]]
37
+ this operation.
38
 
39
+ *Throws:* Timeout-related exceptions [[thread.req.timing]].
40
 
41
+ The expression `m.try_lock_until(abs_time)` is well-formed and has the
42
+ following semantics:
43
 
44
+ *Preconditions:* If `m` is of type `timed_mutex` or
45
+ `shared_timed_mutex`, the calling thread does not own the mutex.
46
 
47
  *Effects:* The function attempts to obtain ownership of the mutex. If
48
  `abs_time` has already passed, the function attempts to obtain ownership
49
+ without blocking (as if by calling `try_lock()`). The function returns
50
+ before the absolute timeout [[thread.req.timing]] specified by
51
  `abs_time` only if it has obtained ownership of the mutex object.
52
 
53
  [*Note 2*: As with `try_lock()`, there is no guarantee that ownership
54
  will be obtained if the lock is available, but implementations are
55
  expected to make a strong effort to do so. — *end note*]
 
58
 
59
  *Returns:* `true` if ownership was obtained, otherwise `false`.
60
 
61
  *Synchronization:* If `try_lock_until()` returns `true`, prior
62
  `unlock()` operations on the same object *synchronize
63
+ with*[[intro.multithread]] this operation.
64
 
65
+ *Throws:* Timeout-related exceptions [[thread.req.timing]].
66
 
67
  ##### Class `timed_mutex` <a id="thread.timedmutex.class">[[thread.timedmutex.class]]</a>
68
 
69
  ``` cpp
70
  namespace std {
 
82
  bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
83
  template<class Clock, class Duration>
84
  bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
85
  void unlock();
86
 
87
+ using native_handle_type = implementation-defined; // see~[thread.req.native]
88
+ native_handle_type native_handle(); // see~[thread.req.native]
89
  };
90
  }
91
  ```
92
 
93
  The class `timed_mutex` provides a non-recursive mutex with exclusive
 
96
  `try_lock()`) or block (for `lock()`, `try_lock_for()`, and
97
  `try_lock_until()`) until the owning thread has released ownership with
98
  a call to `unlock()` or the call to `try_lock_for()` or
99
  `try_lock_until()` times out (having failed to obtain ownership).
100
 
101
+ The class `timed_mutex` meets all of the timed mutex requirements
102
+ [[thread.timedmutex.requirements]]. It is a standard-layout class
103
+ [[class.prop]].
104
 
105
  The behavior of a program is undefined if:
106
 
107
  - it destroys a `timed_mutex` object owned by any thread,
108
  - a thread that owns a `timed_mutex` object calls `lock()`,
 
128
  bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
129
  template<class Clock, class Duration>
130
  bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
131
  void unlock();
132
 
133
+ using native_handle_type = implementation-defined; // see~[thread.req.native]
134
+ native_handle_type native_handle(); // see~[thread.req.native]
135
  };
136
  }
137
  ```
138
 
139
  The class `recursive_timed_mutex` provides a recursive mutex with
 
142
  ownership of that object will fail (for `try_lock()`) or block (for
143
  `lock()`, `try_lock_for()`, and `try_lock_until()`) until the owning
144
  thread has completely released ownership or the call to `try_lock_for()`
145
  or `try_lock_until()` times out (having failed to obtain ownership).
146
 
147
+ The class `recursive_timed_mutex` meets all of the timed mutex
148
+ requirements [[thread.timedmutex.requirements]]. It is a standard-layout
149
+ class [[class.prop]].
150
 
151
  A thread that owns a `recursive_timed_mutex` object may acquire
152
  additional levels of ownership by calling `lock()`, `try_lock()`,
153
  `try_lock_for()`, or `try_lock_until()` on that object. It is
154
  unspecified how many levels of ownership may be acquired by a single
155
  thread. If a thread has already acquired the maximum level of ownership
156
  for a `recursive_timed_mutex` object, additional calls to `try_lock()`,
157
+ `try_lock_for()`, or `try_lock_until()` fail, and additional calls to
158
+ `lock()` throw an exception of type `system_error`. A thread shall call
159
+ `unlock()` once for each level of ownership acquired by calls to
160
+ `lock()`, `try_lock()`, `try_lock_for()`, and `try_lock_until()`. Only
161
+ when all levels of ownership have been released may ownership of the
162
+ object be acquired by another thread.
163
 
164
  The behavior of a program is undefined if:
165
 
166
  - it destroys a `recursive_timed_mutex` object owned by any thread, or
167
  - a thread terminates while owning a `recursive_timed_mutex` object.