tmp/tmp8jjd1i82/{from.md → to.md}
RENAMED
|
@@ -1,74 +1,74 @@
|
|
| 1 |
#### Shared timed mutex types <a id="thread.sharedtimedmutex.requirements">[[thread.sharedtimedmutex.requirements]]</a>
|
| 2 |
|
| 3 |
The standard library type `shared_timed_mutex` is a *shared timed mutex
|
| 4 |
-
type*. Shared timed mutex types
|
| 5 |
-
|
| 6 |
-
[[thread.sharedmutex.requirements]]
|
| 7 |
requirements set out below. In this description, `m` denotes an object
|
| 8 |
of a shared timed mutex type, `rel_type` denotes an object of an
|
| 9 |
-
instantiation of `duration`
|
| 10 |
-
|
| 11 |
|
| 12 |
-
The expression `m.try_lock_shared_for(rel_time)`
|
| 13 |
-
|
| 14 |
|
| 15 |
-
*
|
| 16 |
|
| 17 |
*Effects:* Attempts to obtain shared lock ownership for the calling
|
| 18 |
-
thread within the relative timeout
|
| 19 |
`rel_time`. If the time specified by `rel_time` is less than or equal to
|
| 20 |
`rel_time.zero()`, the function attempts to obtain ownership without
|
| 21 |
-
blocking (as if by calling `try_lock_shared()`). The function
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
[*Note 1*: As with `try_lock()`, there is no guarantee that ownership
|
| 26 |
will be obtained if the lock is available, but implementations are
|
| 27 |
expected to make a strong effort to do so. — *end note*]
|
| 28 |
|
| 29 |
-
If an exception is thrown then a shared lock
|
| 30 |
-
|
| 31 |
|
| 32 |
*Return type:* `bool`.
|
| 33 |
|
| 34 |
*Returns:* `true` if the shared lock was acquired, `false` otherwise.
|
| 35 |
|
| 36 |
*Synchronization:* If `try_lock_shared_for()` returns `true`, prior
|
| 37 |
`unlock()` operations on the same object synchronize
|
| 38 |
-
with
|
| 39 |
|
| 40 |
-
*Throws:* Timeout-related exceptions
|
| 41 |
|
| 42 |
-
The expression `m.try_lock_shared_until(abs_time)`
|
| 43 |
-
|
| 44 |
|
| 45 |
-
*
|
| 46 |
|
| 47 |
*Effects:* The function attempts to obtain shared ownership of the
|
| 48 |
mutex. If `abs_time` has already passed, the function attempts to obtain
|
| 49 |
shared ownership without blocking (as if by calling
|
| 50 |
-
`try_lock_shared()`). The function
|
| 51 |
-
timeout
|
| 52 |
obtained shared ownership of the mutex object.
|
| 53 |
|
| 54 |
[*Note 2*: As with `try_lock()`, there is no guarantee that ownership
|
| 55 |
will be obtained if the lock is available, but implementations are
|
| 56 |
expected to make a strong effort to do so. — *end note*]
|
| 57 |
|
| 58 |
-
If an exception is thrown then a shared lock
|
| 59 |
-
|
| 60 |
|
| 61 |
*Return type:* `bool`.
|
| 62 |
|
| 63 |
*Returns:* `true` if the shared lock was acquired, `false` otherwise.
|
| 64 |
|
| 65 |
*Synchronization:* If `try_lock_shared_until()` returns `true`, prior
|
| 66 |
`unlock()` operations on the same object synchronize
|
| 67 |
-
with
|
| 68 |
|
| 69 |
-
*Throws:* Timeout-related exceptions
|
| 70 |
|
| 71 |
##### Class `shared_timed_mutex` <a id="thread.sharedtimedmutex.class">[[thread.sharedtimedmutex.class]]</a>
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
namespace std {
|
|
@@ -78,39 +78,37 @@ namespace std {
|
|
| 78 |
~shared_timed_mutex();
|
| 79 |
|
| 80 |
shared_timed_mutex(const shared_timed_mutex&) = delete;
|
| 81 |
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
|
| 82 |
|
| 83 |
-
//
|
| 84 |
void lock(); // blocking
|
| 85 |
bool try_lock();
|
| 86 |
template<class Rep, class Period>
|
| 87 |
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
| 88 |
template<class Clock, class Duration>
|
| 89 |
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
| 90 |
void unlock();
|
| 91 |
|
| 92 |
-
//
|
| 93 |
void lock_shared(); // blocking
|
| 94 |
bool try_lock_shared();
|
| 95 |
template<class Rep, class Period>
|
| 96 |
-
bool
|
| 97 |
-
try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
|
| 98 |
template<class Clock, class Duration>
|
| 99 |
-
bool
|
| 100 |
-
try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
|
| 101 |
void unlock_shared();
|
| 102 |
};
|
| 103 |
}
|
| 104 |
```
|
| 105 |
|
| 106 |
The class `shared_timed_mutex` provides a non-recursive mutex with
|
| 107 |
shared ownership semantics.
|
| 108 |
|
| 109 |
-
The class `shared_timed_mutex`
|
| 110 |
-
|
| 111 |
-
|
| 112 |
|
| 113 |
The behavior of a program is undefined if:
|
| 114 |
|
| 115 |
- it destroys a `shared_timed_mutex` object owned by any thread,
|
| 116 |
- a thread attempts to recursively gain any ownership of a
|
|
|
|
| 1 |
#### Shared timed mutex types <a id="thread.sharedtimedmutex.requirements">[[thread.sharedtimedmutex.requirements]]</a>
|
| 2 |
|
| 3 |
The standard library type `shared_timed_mutex` is a *shared timed mutex
|
| 4 |
+
type*. Shared timed mutex types meet the requirements of timed mutex
|
| 5 |
+
types [[thread.timedmutex.requirements]], shared mutex types
|
| 6 |
+
[[thread.sharedmutex.requirements]], and additionally meet the
|
| 7 |
requirements set out below. In this description, `m` denotes an object
|
| 8 |
of a shared timed mutex type, `rel_type` denotes an object of an
|
| 9 |
+
instantiation of `duration` [[time.duration]], and `abs_time` denotes an
|
| 10 |
+
object of an instantiation of `time_point` [[time.point]].
|
| 11 |
|
| 12 |
+
The expression `m.try_lock_shared_for(rel_time)` is well-formed and has
|
| 13 |
+
the following semantics:
|
| 14 |
|
| 15 |
+
*Preconditions:* The calling thread has no ownership of the mutex.
|
| 16 |
|
| 17 |
*Effects:* Attempts to obtain shared lock ownership for the calling
|
| 18 |
+
thread within the relative timeout [[thread.req.timing]] specified by
|
| 19 |
`rel_time`. If the time specified by `rel_time` is less than or equal to
|
| 20 |
`rel_time.zero()`, the function attempts to obtain ownership without
|
| 21 |
+
blocking (as if by calling `try_lock_shared()`). The function returns
|
| 22 |
+
within the timeout specified by `rel_time` only if it has obtained
|
| 23 |
+
shared ownership of the mutex object.
|
| 24 |
|
| 25 |
[*Note 1*: As with `try_lock()`, there is no guarantee that ownership
|
| 26 |
will be obtained if the lock is available, but implementations are
|
| 27 |
expected to make a strong effort to do so. — *end note*]
|
| 28 |
|
| 29 |
+
If an exception is thrown then a shared lock has not been acquired for
|
| 30 |
+
the current thread.
|
| 31 |
|
| 32 |
*Return type:* `bool`.
|
| 33 |
|
| 34 |
*Returns:* `true` if the shared lock was acquired, `false` otherwise.
|
| 35 |
|
| 36 |
*Synchronization:* If `try_lock_shared_for()` returns `true`, prior
|
| 37 |
`unlock()` operations on the same object synchronize
|
| 38 |
+
with [[intro.multithread]] this operation.
|
| 39 |
|
| 40 |
+
*Throws:* Timeout-related exceptions [[thread.req.timing]].
|
| 41 |
|
| 42 |
+
The expression `m.try_lock_shared_until(abs_time)` is well-formed and
|
| 43 |
+
has the following semantics:
|
| 44 |
|
| 45 |
+
*Preconditions:* The calling thread has no ownership of the mutex.
|
| 46 |
|
| 47 |
*Effects:* The function attempts to obtain shared ownership of the
|
| 48 |
mutex. If `abs_time` has already passed, the function attempts to obtain
|
| 49 |
shared ownership without blocking (as if by calling
|
| 50 |
+
`try_lock_shared()`). The function returns before the absolute
|
| 51 |
+
timeout [[thread.req.timing]] specified by `abs_time` only if it has
|
| 52 |
obtained shared ownership of the mutex object.
|
| 53 |
|
| 54 |
[*Note 2*: As with `try_lock()`, there is no guarantee that ownership
|
| 55 |
will be obtained if the lock is available, but implementations are
|
| 56 |
expected to make a strong effort to do so. — *end note*]
|
| 57 |
|
| 58 |
+
If an exception is thrown then a shared lock has not been acquired for
|
| 59 |
+
the current thread.
|
| 60 |
|
| 61 |
*Return type:* `bool`.
|
| 62 |
|
| 63 |
*Returns:* `true` if the shared lock was acquired, `false` otherwise.
|
| 64 |
|
| 65 |
*Synchronization:* If `try_lock_shared_until()` returns `true`, prior
|
| 66 |
`unlock()` operations on the same object synchronize
|
| 67 |
+
with [[intro.multithread]] this operation.
|
| 68 |
|
| 69 |
+
*Throws:* Timeout-related exceptions [[thread.req.timing]].
|
| 70 |
|
| 71 |
##### Class `shared_timed_mutex` <a id="thread.sharedtimedmutex.class">[[thread.sharedtimedmutex.class]]</a>
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
namespace std {
|
|
|
|
| 78 |
~shared_timed_mutex();
|
| 79 |
|
| 80 |
shared_timed_mutex(const shared_timed_mutex&) = delete;
|
| 81 |
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
|
| 82 |
|
| 83 |
+
// exclusive ownership
|
| 84 |
void lock(); // blocking
|
| 85 |
bool try_lock();
|
| 86 |
template<class Rep, class Period>
|
| 87 |
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
| 88 |
template<class Clock, class Duration>
|
| 89 |
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
| 90 |
void unlock();
|
| 91 |
|
| 92 |
+
// shared ownership
|
| 93 |
void lock_shared(); // blocking
|
| 94 |
bool try_lock_shared();
|
| 95 |
template<class Rep, class Period>
|
| 96 |
+
bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
|
|
|
|
| 97 |
template<class Clock, class Duration>
|
| 98 |
+
bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
|
|
|
|
| 99 |
void unlock_shared();
|
| 100 |
};
|
| 101 |
}
|
| 102 |
```
|
| 103 |
|
| 104 |
The class `shared_timed_mutex` provides a non-recursive mutex with
|
| 105 |
shared ownership semantics.
|
| 106 |
|
| 107 |
+
The class `shared_timed_mutex` meets all of the shared timed mutex
|
| 108 |
+
requirements [[thread.sharedtimedmutex.requirements]]. It is a
|
| 109 |
+
standard-layout class [[class.prop]].
|
| 110 |
|
| 111 |
The behavior of a program is undefined if:
|
| 112 |
|
| 113 |
- it destroys a `shared_timed_mutex` object owned by any thread,
|
| 114 |
- a thread attempts to recursively gain any ownership of a
|