You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modifications after `P3832R1:SG1:Brno_2026` meeting:
16
+
17
+
- Rewrote Effects to explicitly describe the algorithm: `try_lock_until` on one lockable, then `try_lock()` on the rest, with unlock-and-retry semantics.
18
+
- Added "This function does not rely on timeouts for deadlock avoidance."
19
+
- Changed "An implementation should ensure..." to normative "This function does not consistently return ≥ 0 in the absence of contending mutex acquisitions."
20
+
- Removed `try_lock_for()` from Effects; the algorithm is now specified in terms of `try_lock_until()` and `try_lock()` only.
21
+
- Rewrote Returns to: "the index of the lockable that the implementation was attempting to acquire when the time point `abs_time` was reached."
22
+
- Dropped "in `Ls`" from Preconditions to match standard style.
int try_lock_until(const chrono::time_point<Clock, Duration>& abs_time, Ls&... ls);
80
91
```
81
92
82
-
**6** *Preconditions*: Each template parameter type in `Ls`meets the *Cpp17TimedLockable* requirements.
93
+
**6** *Preconditions*: Each template parameter type meets the *Cpp17TimedLockable* requirements.
83
94
84
-
**7** *Effects*: Attempts to obtain ownership of all arguments via repeated calls to `try_lock_until()`, `try_lock_for()`, `try_lock()` or `unlock()` on each argument. The sequence of calls does not result in deadlock. No call to `try_lock_for()` or `try_lock_until()` is made while holding a lock on any argument, but the sequence is otherwise unspecified. If all locks are acquired before `abs_time` has passed, returns `-1`. If the time point `abs_time` is reached before all locks are acquired, releases any locks it holds and returns the index of the lockable for which `try_lock_until()` or `try_lock_for()` failed due to `abs_time` being reached. If a call to `try_lock_until()`, `try_lock_for()` or `try_lock()` throws an exception, `unlock()` is called on any object locked by this algorithm prior to the exception, and the exception is rethrown.<br>An implementation should ensure that `try_lock_until()` does not consistently return ≥ 0 in the absence of contending mutex acquisitions.
95
+
**7** *Effects*: Calls `try_lock_until(l, abs_time)` on an unspecified lockable `l` from `ls`. If this returns `true`, then `try_lock()` is called on the other lockables of `ls` in an unspecified order until all have been locked or one fails. If all calls to `try_lock()` return `true`, the overall operation succeeds. Otherwise, `unlock()` is called for all lockables for which `try_lock()` or `try_lock_until()` returned `true`, and the above steps are repeated until the time point `abs_time` has been reached. The sequence in which locks are obtained does not result in deadlock. This function does not rely on timeouts for deadlock avoidance. This function does not consistently return ≥ 0 in the absence of contending mutex acquisitions. If a call to `try_lock_until()` or `try_lock()` throws an exception, `unlock()` is called for any lockable that was locked by this algorithm prior to the exception, and the exception is rethrown.<br>[*Note 1*: The lockable `l` chosen may be the same or different for multiple executions of the loop. — *end note*]
85
96
86
-
**8** *Returns*: `-1` if all locks were obtained, otherwise the index of the lockable for which `try_lock_until()` or `try_lock_for()` failed due to `abs_time`being reached.
97
+
**8** *Returns*: `-1` if all locks were obtained, otherwise the index of the lockable that the implementation was attempting to acquire when the time point `abs_time`was reached.
87
98
88
-
**9** *Throws*: Any exception thrown by the lockable `try_lock_until()`, `try_lock_for()`, or `try_lock()` functions.
99
+
**9** *Throws*: Any exception thrown by the lockable `try_lock_until()` or `try_lock()` functions.
89
100
90
101
```cpp
91
102
template <classRep, class Period, class... Ls>
92
103
int try_lock_for(const chrono::duration<Rep, Period>& rel_time, Ls&... ls);
93
104
```
94
105
95
-
**9** *Preconditions*: Each template parameter type in `Ls` meets the *Cpp17TimedLockable* requirements.
106
+
**9** *Preconditions*: Each template parameter type meets the *Cpp17TimedLockable* requirements.
0 commit comments