tmp/tmp5uquectq/{from.md → to.md}
RENAMED
|
@@ -6,52 +6,49 @@ namespace std {
|
|
| 6 |
class scoped_lock {
|
| 7 |
public:
|
| 8 |
using mutex_type = Mutex; // If MutexTypes... consists of the single type Mutex
|
| 9 |
|
| 10 |
explicit scoped_lock(MutexTypes&... m);
|
| 11 |
-
explicit scoped_lock(MutexTypes&... m
|
| 12 |
~scoped_lock();
|
| 13 |
|
| 14 |
scoped_lock(const scoped_lock&) = delete;
|
| 15 |
scoped_lock& operator=(const scoped_lock&) = delete;
|
| 16 |
|
| 17 |
private:
|
| 18 |
tuple<MutexTypes&...> pm; // exposition only
|
| 19 |
};
|
| 20 |
-
|
| 21 |
-
template<class... MutexTypes>
|
| 22 |
-
scoped_lock(scoped_lock<MutexTypes...>) -> scoped_lock<MutexTypes...>;
|
| 23 |
}
|
| 24 |
```
|
| 25 |
|
| 26 |
An object of type `scoped_lock` controls the ownership of lockable
|
| 27 |
objects within a scope. A `scoped_lock` object maintains ownership of
|
| 28 |
-
lockable objects throughout the `scoped_lock` object’s lifetime
|
| 29 |
-
[[basic.life]]
|
| 30 |
objects referenced by `pm` do not exist for the entire lifetime of the
|
| 31 |
`scoped_lock` object. When `sizeof...(MutexTypes)` is `1`, the supplied
|
| 32 |
-
`Mutex` type shall meet the
|
| 33 |
-
[[thread.req.lockable.basic]]
|
| 34 |
-
meet the
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
explicit scoped_lock(MutexTypes&... m);
|
| 38 |
```
|
| 39 |
|
| 40 |
-
*
|
| 41 |
-
thread does not own the corresponding mutex element of `m`.
|
| 42 |
|
| 43 |
*Effects:* Initializes `pm` with `tie(m...)`. Then if
|
| 44 |
`sizeof...(MutexTypes)` is `0`, no effects. Otherwise if
|
| 45 |
`sizeof...(MutexTypes)` is `1`, then `m.lock()`. Otherwise,
|
| 46 |
`lock(m...)`.
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
-
explicit scoped_lock(MutexTypes&... m
|
| 50 |
```
|
| 51 |
|
| 52 |
-
*
|
| 53 |
|
| 54 |
*Effects:* Initializes `pm` with `tie(m...)`.
|
| 55 |
|
| 56 |
*Throws:* Nothing.
|
| 57 |
|
|
|
|
| 6 |
class scoped_lock {
|
| 7 |
public:
|
| 8 |
using mutex_type = Mutex; // If MutexTypes... consists of the single type Mutex
|
| 9 |
|
| 10 |
explicit scoped_lock(MutexTypes&... m);
|
| 11 |
+
explicit scoped_lock(adopt_lock_t, MutexTypes&... m);
|
| 12 |
~scoped_lock();
|
| 13 |
|
| 14 |
scoped_lock(const scoped_lock&) = delete;
|
| 15 |
scoped_lock& operator=(const scoped_lock&) = delete;
|
| 16 |
|
| 17 |
private:
|
| 18 |
tuple<MutexTypes&...> pm; // exposition only
|
| 19 |
};
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
```
|
| 22 |
|
| 23 |
An object of type `scoped_lock` controls the ownership of lockable
|
| 24 |
objects within a scope. A `scoped_lock` object maintains ownership of
|
| 25 |
+
lockable objects throughout the `scoped_lock` object’s lifetime
|
| 26 |
+
[[basic.life]]. The behavior of a program is undefined if the lockable
|
| 27 |
objects referenced by `pm` do not exist for the entire lifetime of the
|
| 28 |
`scoped_lock` object. When `sizeof...(MutexTypes)` is `1`, the supplied
|
| 29 |
+
`Mutex` type shall meet the *Cpp17BasicLockable* requirements
|
| 30 |
+
[[thread.req.lockable.basic]]. Otherwise, each of the mutex types shall
|
| 31 |
+
meet the *Cpp17Lockable* requirements [[thread.req.lockable.req]].
|
| 32 |
|
| 33 |
``` cpp
|
| 34 |
explicit scoped_lock(MutexTypes&... m);
|
| 35 |
```
|
| 36 |
|
| 37 |
+
*Preconditions:* If a `MutexTypes` type is not a recursive mutex, the
|
| 38 |
+
calling thread does not own the corresponding mutex element of `m`.
|
| 39 |
|
| 40 |
*Effects:* Initializes `pm` with `tie(m...)`. Then if
|
| 41 |
`sizeof...(MutexTypes)` is `0`, no effects. Otherwise if
|
| 42 |
`sizeof...(MutexTypes)` is `1`, then `m.lock()`. Otherwise,
|
| 43 |
`lock(m...)`.
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
+
explicit scoped_lock(adopt_lock_t, MutexTypes&... m);
|
| 47 |
```
|
| 48 |
|
| 49 |
+
*Preconditions:* The calling thread owns all the mutexes in `m`.
|
| 50 |
|
| 51 |
*Effects:* Initializes `pm` with `tie(m...)`.
|
| 52 |
|
| 53 |
*Throws:* Nothing.
|
| 54 |
|