tmp/tmp_l5zyz_b/{from.md → to.md}
RENAMED
|
@@ -1,13 +1,18 @@
|
|
| 1 |
#### Shared mutex types <a id="thread.sharedmutex.requirements">[[thread.sharedmutex.requirements]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
The standard library types `shared_mutex` and `shared_timed_mutex` are
|
| 4 |
*shared mutex types*. Shared mutex types meet the requirements of mutex
|
| 5 |
types [[thread.mutex.requirements.mutex]] and additionally meet the
|
| 6 |
requirements set out below. In this description, `m` denotes an object
|
| 7 |
of a shared mutex type.
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
In addition to the exclusive lock ownership mode specified in
|
| 10 |
[[thread.mutex.requirements.mutex]], shared mutex types provide a
|
| 11 |
*shared lock* ownership mode. Multiple execution agents can
|
| 12 |
simultaneously hold a shared lock ownership of a shared mutex type. But
|
| 13 |
no execution agent holds a shared lock while another execution agent
|
|
@@ -26,17 +31,17 @@ semantics:
|
|
| 26 |
|
| 27 |
*Effects:* Blocks the calling thread until shared ownership of the mutex
|
| 28 |
can be obtained for the calling thread. If an exception is thrown then a
|
| 29 |
shared lock has not been acquired for the current thread.
|
| 30 |
|
| 31 |
-
*Ensures:* The calling thread has a shared lock on the mutex.
|
| 32 |
-
|
| 33 |
-
*Return type:* `void`.
|
| 34 |
-
|
| 35 |
*Synchronization:* Prior `unlock()` operations on the same object
|
| 36 |
synchronize with [[intro.multithread]] this operation.
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
*Throws:* `system_error` when an exception is
|
| 39 |
required [[thread.req.exception]].
|
| 40 |
|
| 41 |
*Error conditions:*
|
| 42 |
|
|
@@ -70,19 +75,18 @@ following semantics:
|
|
| 70 |
calling thread without blocking. If shared ownership is not obtained,
|
| 71 |
there is no effect and `try_lock_shared()` immediately returns. An
|
| 72 |
implementation may fail to obtain the lock even if it is not held by any
|
| 73 |
other thread.
|
| 74 |
|
| 75 |
-
*Return type:* `bool`.
|
| 76 |
-
|
| 77 |
-
*Returns:* `true` if the shared ownership lock was acquired, `false`
|
| 78 |
-
otherwise.
|
| 79 |
-
|
| 80 |
*Synchronization:* If `try_lock_shared()` returns `true`, prior
|
| 81 |
`unlock()` operations on the same object synchronize
|
| 82 |
with [[intro.multithread]] this operation.
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
*Throws:* Nothing.
|
| 85 |
|
| 86 |
##### Class `shared_mutex` <a id="thread.sharedmutex.class">[[thread.sharedmutex.class]]</a>
|
| 87 |
|
| 88 |
``` cpp
|
|
|
|
| 1 |
#### Shared mutex types <a id="thread.sharedmutex.requirements">[[thread.sharedmutex.requirements]]</a>
|
| 2 |
|
| 3 |
+
##### General <a id="thread.sharedmutex.requirements.general">[[thread.sharedmutex.requirements.general]]</a>
|
| 4 |
+
|
| 5 |
The standard library types `shared_mutex` and `shared_timed_mutex` are
|
| 6 |
*shared mutex types*. Shared mutex types meet the requirements of mutex
|
| 7 |
types [[thread.mutex.requirements.mutex]] and additionally meet the
|
| 8 |
requirements set out below. In this description, `m` denotes an object
|
| 9 |
of a shared mutex type.
|
| 10 |
|
| 11 |
+
[*Note 1*: The shared mutex types meet the *Cpp17SharedLockable*
|
| 12 |
+
requirements [[thread.req.lockable.shared]]. — *end note*]
|
| 13 |
+
|
| 14 |
In addition to the exclusive lock ownership mode specified in
|
| 15 |
[[thread.mutex.requirements.mutex]], shared mutex types provide a
|
| 16 |
*shared lock* ownership mode. Multiple execution agents can
|
| 17 |
simultaneously hold a shared lock ownership of a shared mutex type. But
|
| 18 |
no execution agent holds a shared lock while another execution agent
|
|
|
|
| 31 |
|
| 32 |
*Effects:* Blocks the calling thread until shared ownership of the mutex
|
| 33 |
can be obtained for the calling thread. If an exception is thrown then a
|
| 34 |
shared lock has not been acquired for the current thread.
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
*Synchronization:* Prior `unlock()` operations on the same object
|
| 37 |
synchronize with [[intro.multithread]] this operation.
|
| 38 |
|
| 39 |
+
*Ensures:* The calling thread has a shared lock on the mutex.
|
| 40 |
+
|
| 41 |
+
*Return type:* `void`.
|
| 42 |
+
|
| 43 |
*Throws:* `system_error` when an exception is
|
| 44 |
required [[thread.req.exception]].
|
| 45 |
|
| 46 |
*Error conditions:*
|
| 47 |
|
|
|
|
| 75 |
calling thread without blocking. If shared ownership is not obtained,
|
| 76 |
there is no effect and `try_lock_shared()` immediately returns. An
|
| 77 |
implementation may fail to obtain the lock even if it is not held by any
|
| 78 |
other thread.
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
*Synchronization:* If `try_lock_shared()` returns `true`, prior
|
| 81 |
`unlock()` operations on the same object synchronize
|
| 82 |
with [[intro.multithread]] this operation.
|
| 83 |
|
| 84 |
+
*Return type:* `bool`.
|
| 85 |
+
|
| 86 |
+
*Returns:* `true` if the shared lock was acquired, otherwise `false`.
|
| 87 |
+
|
| 88 |
*Throws:* Nothing.
|
| 89 |
|
| 90 |
##### Class `shared_mutex` <a id="thread.sharedmutex.class">[[thread.sharedmutex.class]]</a>
|
| 91 |
|
| 92 |
``` cpp
|