From Jason Turner

[thread.sharedmutex.requirements]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8wqwlc43/{from.md → to.md} +35 -35
tmp/tmp8wqwlc43/{from.md → to.md} RENAMED
@@ -1,72 +1,72 @@
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 shall meet the requirements of
5
- mutex types ([[thread.mutex.requirements.mutex]]), and additionally
6
- shall meet the requirements set out below. In this description, `m`
7
- denotes an object 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 shall hold a shared lock while another execution
14
- agent holds an exclusive lock on the same shared mutex type, and
15
- vice-versa. The maximum number of execution agents which can share a
16
- shared lock on a single shared mutex type is unspecified, but shall be
17
- at least 10000. If more than the maximum number of execution agents
18
- attempt to obtain a shared lock, the excess execution agents shall block
19
- until the number of shared locks are reduced below the maximum amount by
20
- other execution agents releasing their shared lock.
21
 
22
- The expression `m.lock_shared()` shall be well-formed and have the
23
- following semantics:
24
 
25
- *Requires:* The calling thread has no ownership of the mutex.
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 shall not have been acquired for the current thread.
30
 
31
- *Postconditions:* 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 shall
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
 
43
  - `operation_not_permitted` — if the thread does not have the privilege
44
  to perform the operation.
45
  - `resource_deadlock_would_occur` — if the implementation detects that a
46
  deadlock would occur.
47
 
48
- The expression `m.unlock_shared()` shall be well-formed and have the
49
- following semantics:
50
 
51
- *Requires:* The calling thread shall hold a shared lock on the mutex.
52
 
53
  *Effects:* Releases a shared lock on the mutex held by the calling
54
  thread.
55
 
56
  *Return type:* `void`.
57
 
58
  *Synchronization:* This operation synchronizes
59
- with ([[intro.multithread]]) subsequent `lock()` operations that obtain
60
  ownership on the same object.
61
 
62
  *Throws:* Nothing.
63
 
64
- The expression `m.try_lock_shared()` shall be well-formed and have the
65
  following semantics:
66
 
67
- *Requires:* The calling thread has no ownership of the mutex.
68
 
69
  *Effects:* Attempts to obtain shared ownership of the mutex for the
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
@@ -77,15 +77,15 @@ other thread.
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
89
  namespace std {
90
  class shared_mutex {
91
  public:
@@ -93,32 +93,32 @@ namespace std {
93
  ~shared_mutex();
94
 
95
  shared_mutex(const shared_mutex&) = delete;
96
  shared_mutex& operator=(const shared_mutex&) = delete;
97
 
98
- // Exclusive ownership
99
  void lock(); // blocking
100
  bool try_lock();
101
  void unlock();
102
 
103
- // Shared ownership
104
  void lock_shared(); // blocking
105
  bool try_lock_shared();
106
  void unlock_shared();
107
 
108
- using native_handle_type = implementation-defined; // See~[thread.req.native]
109
- native_handle_type native_handle(); // See~[thread.req.native]
110
  };
111
  }
112
  ```
113
 
114
  The class `shared_mutex` provides a non-recursive mutex with shared
115
  ownership semantics.
116
 
117
- The class `shared_mutex` shall satisfy all of the shared mutex
118
- requirements ([[thread.sharedmutex.requirements]]). It shall be a
119
- standard-layout class (Clause  [[class]]).
120
 
121
  The behavior of a program is undefined if:
122
 
123
  - it destroys a `shared_mutex` object owned by any thread,
124
  - a thread attempts to recursively gain any ownership of a
 
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
14
+ holds an exclusive lock on the same shared mutex type, and vice-versa.
15
+ The maximum number of execution agents which can share a shared lock on
16
+ a single shared mutex type is unspecified, but is at least 10000. If
17
+ more than the maximum number of execution agents attempt to obtain a
18
+ shared lock, the excess execution agents block until the number of
19
+ shared locks are reduced below the maximum amount by other execution
20
+ agents releasing their shared lock.
21
 
22
+ The expression `m.lock_shared()` is well-formed and has the following
23
+ semantics:
24
 
25
+ *Preconditions:* The calling thread has no ownership of the mutex.
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
 
43
  - `operation_not_permitted` — if the thread does not have the privilege
44
  to perform the operation.
45
  - `resource_deadlock_would_occur` — if the implementation detects that a
46
  deadlock would occur.
47
 
48
+ The expression `m.unlock_shared()` is well-formed and has the following
49
+ semantics:
50
 
51
+ *Preconditions:* The calling thread holds a shared lock on the mutex.
52
 
53
  *Effects:* Releases a shared lock on the mutex held by the calling
54
  thread.
55
 
56
  *Return type:* `void`.
57
 
58
  *Synchronization:* This operation synchronizes
59
+ with [[intro.multithread]] subsequent `lock()` operations that obtain
60
  ownership on the same object.
61
 
62
  *Throws:* Nothing.
63
 
64
+ The expression `m.try_lock_shared()` is well-formed and has the
65
  following semantics:
66
 
67
+ *Preconditions:* The calling thread has no ownership of the mutex.
68
 
69
  *Effects:* Attempts to obtain shared ownership of the mutex for the
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
 
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
89
  namespace std {
90
  class shared_mutex {
91
  public:
 
93
  ~shared_mutex();
94
 
95
  shared_mutex(const shared_mutex&) = delete;
96
  shared_mutex& operator=(const shared_mutex&) = delete;
97
 
98
+ // exclusive ownership
99
  void lock(); // blocking
100
  bool try_lock();
101
  void unlock();
102
 
103
+ // shared ownership
104
  void lock_shared(); // blocking
105
  bool try_lock_shared();
106
  void unlock_shared();
107
 
108
+ using native_handle_type = implementation-defined; // see~[thread.req.native]
109
+ native_handle_type native_handle(); // see~[thread.req.native]
110
  };
111
  }
112
  ```
113
 
114
  The class `shared_mutex` provides a non-recursive mutex with shared
115
  ownership semantics.
116
 
117
+ The class `shared_mutex` meets all of the shared mutex requirements
118
+ [[thread.sharedmutex.requirements]]. It is a standard-layout class
119
+ [[class.prop]].
120
 
121
  The behavior of a program is undefined if:
122
 
123
  - it destroys a `shared_mutex` object owned by any thread,
124
  - a thread attempts to recursively gain any ownership of a