tmp/tmp1wlmbqxt/{from.md → to.md}
RENAMED
|
@@ -1,35 +1,36 @@
|
|
| 1 |
#### Timed mutex types <a id="thread.timedmutex.requirements">[[thread.timedmutex.requirements]]</a>
|
| 2 |
|
| 3 |
-
The *timed mutex types* are the standard library types
|
| 4 |
-
`
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
`
|
| 8 |
-
[[time.
|
| 9 |
-
of `time_point` ([[time.point]]).
|
| 10 |
|
| 11 |
The timed mutex types shall meet the `TimedLockable` requirements (
|
| 12 |
[[thread.req.lockable.timed]]).
|
| 13 |
|
| 14 |
The expression `m.try_lock_for(rel_time)` shall be well-formed and have
|
| 15 |
the following semantics:
|
| 16 |
|
| 17 |
-
If `m` is of type `
|
| 18 |
calling thread does not own the mutex.
|
| 19 |
|
| 20 |
*Effects:* The function attempts to obtain ownership of the mutex within
|
| 21 |
the relative timeout ([[thread.req.timing]]) specified by `rel_time`.
|
| 22 |
If the time specified by `rel_time` is less than or equal to
|
| 23 |
`rel_time.zero()`, the function attempts to obtain ownership without
|
| 24 |
blocking (as if by calling `try_lock()`). The function shall return
|
| 25 |
within the timeout specified by `rel_time` only if it has obtained
|
| 26 |
-
ownership of the mutex object.
|
| 27 |
-
guarantee that ownership will be obtained if the lock is available, but
|
| 28 |
-
implementations are expected to make a strong effort to do so.
|
| 29 |
|
| 30 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
*Returns:* `true` if ownership was obtained, otherwise `false`.
|
| 33 |
|
| 34 |
*Synchronization:* If `try_lock_for()` returns `true`, prior `unlock()`
|
| 35 |
operations on the same object *synchronize
|
|
@@ -38,23 +39,24 @@ with* ([[intro.multithread]]) this operation.
|
|
| 38 |
*Throws:* Timeout-related exceptions ([[thread.req.timing]]).
|
| 39 |
|
| 40 |
The expression `m.try_lock_until(abs_time)` shall be well-formed and
|
| 41 |
have the following semantics:
|
| 42 |
|
| 43 |
-
*Requires:* If `m` is of type `
|
| 44 |
-
|
| 45 |
|
| 46 |
*Effects:* The function attempts to obtain ownership of the mutex. If
|
| 47 |
`abs_time` has already passed, the function attempts to obtain ownership
|
| 48 |
without blocking (as if by calling `try_lock()`). The function shall
|
| 49 |
return before the absolute timeout ([[thread.req.timing]]) specified by
|
| 50 |
-
`abs_time` only if it has obtained ownership of the mutex object.
|
| 51 |
-
with `try_lock()`, there is no guarantee that ownership will be obtained
|
| 52 |
-
if the lock is available, but implementations are expected to make a
|
| 53 |
-
strong effort to do so.
|
| 54 |
|
| 55 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
*Returns:* `true` if ownership was obtained, otherwise `false`.
|
| 58 |
|
| 59 |
*Synchronization:* If `try_lock_until()` returns `true`, prior
|
| 60 |
`unlock()` operations on the same object *synchronize
|
|
@@ -80,11 +82,11 @@ namespace std {
|
|
| 80 |
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
| 81 |
template <class Clock, class Duration>
|
| 82 |
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
| 83 |
void unlock();
|
| 84 |
|
| 85 |
-
|
| 86 |
native_handle_type native_handle(); // See~[thread.req.native]
|
| 87 |
};
|
| 88 |
}
|
| 89 |
```
|
| 90 |
|
|
@@ -94,11 +96,11 @@ by another thread to acquire ownership of that object will fail (for
|
|
| 94 |
`try_lock()`) or block (for `lock()`, `try_lock_for()`, and
|
| 95 |
`try_lock_until()`) until the owning thread has released ownership with
|
| 96 |
a call to `unlock()` or the call to `try_lock_for()` or
|
| 97 |
`try_lock_until()` times out (having failed to obtain ownership).
|
| 98 |
|
| 99 |
-
The class `timed_mutex` shall satisfy all of the
|
| 100 |
requirements ([[thread.timedmutex.requirements]]). It shall be a
|
| 101 |
standard-layout class (Clause [[class]]).
|
| 102 |
|
| 103 |
The behavior of a program is undefined if:
|
| 104 |
|
|
@@ -126,11 +128,11 @@ namespace std {
|
|
| 126 |
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
| 127 |
template <class Clock, class Duration>
|
| 128 |
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
| 129 |
void unlock();
|
| 130 |
|
| 131 |
-
|
| 132 |
native_handle_type native_handle(); // See~[thread.req.native]
|
| 133 |
};
|
| 134 |
}
|
| 135 |
```
|
| 136 |
|
|
@@ -140,11 +142,11 @@ exclusive ownership semantics. If one thread owns a
|
|
| 140 |
ownership of that object will fail (for `try_lock()`) or block (for
|
| 141 |
`lock()`, `try_lock_for()`, and `try_lock_until()`) until the owning
|
| 142 |
thread has completely released ownership or the call to `try_lock_for()`
|
| 143 |
or `try_lock_until()` times out (having failed to obtain ownership).
|
| 144 |
|
| 145 |
-
The class `recursive_timed_mutex` shall satisfy all of the
|
| 146 |
requirements ([[thread.timedmutex.requirements]]). It shall be a
|
| 147 |
standard-layout class (Clause [[class]]).
|
| 148 |
|
| 149 |
A thread that owns a `recursive_timed_mutex` object may acquire
|
| 150 |
additional levels of ownership by calling `lock()`, `try_lock()`,
|
|
|
|
| 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
|
|
|
|
| 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*]
|
| 56 |
+
|
| 57 |
+
*Return type:* `bool`.
|
| 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
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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()`,
|