tmp/tmp4f7jvm6p/{from.md → to.md}
RENAMED
|
@@ -1,38 +1,38 @@
|
|
| 1 |
-
### Requirements for
|
| 2 |
|
| 3 |
#### In general <a id="thread.req.lockable.general">[[thread.req.lockable.general]]</a>
|
| 4 |
|
| 5 |
An *execution agent* is an entity such as a thread that may perform work
|
| 6 |
in parallel with other execution agents.
|
| 7 |
|
| 8 |
-
[*Note 1*: Implementations or users
|
| 9 |
such as processes or thread-pool tasks. — *end note*]
|
| 10 |
|
| 11 |
-
The calling agent is determined by context, e.g. the calling thread
|
| 12 |
-
contains the call, and so on.
|
| 13 |
|
| 14 |
[*Note 2*: Some lockable objects are “agent oblivious” in that they
|
| 15 |
work for any execution agent model because they do not determine or
|
| 16 |
store the agent’s ID (e.g., an ordinary spin lock). — *end note*]
|
| 17 |
|
| 18 |
-
The standard library templates `unique_lock`
|
| 19 |
-
`shared_lock`
|
| 20 |
-
[[thread.lock.scoped]]
|
| 21 |
-
`try_lock`
|
| 22 |
-
[[thread.condition.condvarany]]
|
| 23 |
-
objects. The
|
| 24 |
-
and the
|
| 25 |
-
these library types in order to acquire or
|
| 26 |
-
by a given execution agent.
|
| 27 |
|
| 28 |
[*Note 3*: The nature of any lock ownership and any synchronization it
|
| 29 |
-
|
| 30 |
|
| 31 |
-
####
|
| 32 |
|
| 33 |
-
A type `L` meets the
|
| 34 |
expressions are well-formed and have the specified semantics (`m`
|
| 35 |
denotes a value of type `L`).
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
m.lock()
|
|
@@ -44,20 +44,20 @@ acquired for the current execution agent.
|
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
m.unlock()
|
| 47 |
```
|
| 48 |
|
| 49 |
-
*
|
| 50 |
|
| 51 |
*Effects:* Releases a lock on `m` held by the current execution agent.
|
| 52 |
|
| 53 |
*Throws:* Nothing.
|
| 54 |
|
| 55 |
-
####
|
| 56 |
|
| 57 |
-
A type `L` meets the
|
| 58 |
-
|
| 59 |
well-formed and have the specified semantics (`m` denotes a value of
|
| 60 |
type `L`).
|
| 61 |
|
| 62 |
``` cpp
|
| 63 |
m.try_lock()
|
|
@@ -69,44 +69,44 @@ been acquired for the current execution agent.
|
|
| 69 |
|
| 70 |
*Return type:* `bool`.
|
| 71 |
|
| 72 |
*Returns:* `true` if the lock was acquired, `false` otherwise.
|
| 73 |
|
| 74 |
-
####
|
| 75 |
|
| 76 |
-
A type `L` meets the
|
| 77 |
-
|
| 78 |
-
and have the specified semantics (`m` denotes a value of
|
| 79 |
-
`rel_time` denotes a value of an instantiation of `duration`
|
| 80 |
-
[[time.duration]]
|
| 81 |
-
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
m.try_lock_for(rel_time)
|
| 85 |
```
|
| 86 |
|
| 87 |
*Effects:* Attempts to acquire a lock for the current execution agent
|
| 88 |
-
within the relative timeout
|
| 89 |
-
`rel_time`. The function
|
| 90 |
-
|
| 91 |
-
execution agent. If an exception is thrown then a lock
|
| 92 |
-
|
| 93 |
|
| 94 |
*Return type:* `bool`.
|
| 95 |
|
| 96 |
*Returns:* `true` if the lock was acquired, `false` otherwise.
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
m.try_lock_until(abs_time)
|
| 100 |
```
|
| 101 |
|
| 102 |
*Effects:* Attempts to acquire a lock for the current execution agent
|
| 103 |
-
before the absolute timeout
|
| 104 |
-
`abs_time`. The function
|
| 105 |
-
|
| 106 |
-
execution agent. If an exception is thrown then a lock
|
| 107 |
-
|
| 108 |
|
| 109 |
*Return type:* `bool`.
|
| 110 |
|
| 111 |
*Returns:* `true` if the lock was acquired, `false` otherwise.
|
| 112 |
|
|
|
|
| 1 |
+
### Requirements for *Cpp17Lockable* types <a id="thread.req.lockable">[[thread.req.lockable]]</a>
|
| 2 |
|
| 3 |
#### In general <a id="thread.req.lockable.general">[[thread.req.lockable.general]]</a>
|
| 4 |
|
| 5 |
An *execution agent* is an entity such as a thread that may perform work
|
| 6 |
in parallel with other execution agents.
|
| 7 |
|
| 8 |
+
[*Note 1*: Implementations or users can introduce other kinds of agents
|
| 9 |
such as processes or thread-pool tasks. — *end note*]
|
| 10 |
|
| 11 |
+
The calling agent is determined by context, e.g., the calling thread
|
| 12 |
+
that contains the call, and so on.
|
| 13 |
|
| 14 |
[*Note 2*: Some lockable objects are “agent oblivious” in that they
|
| 15 |
work for any execution agent model because they do not determine or
|
| 16 |
store the agent’s ID (e.g., an ordinary spin lock). — *end note*]
|
| 17 |
|
| 18 |
+
The standard library templates `unique_lock` [[thread.lock.unique]],
|
| 19 |
+
`shared_lock` [[thread.lock.shared]], `scoped_lock`
|
| 20 |
+
[[thread.lock.scoped]], `lock_guard` [[thread.lock.guard]], `lock`,
|
| 21 |
+
`try_lock` [[thread.lock.algorithm]], and `condition_variable_any`
|
| 22 |
+
[[thread.condition.condvarany]] all operate on user-supplied lockable
|
| 23 |
+
objects. The *Cpp17BasicLockable* requirements, the *Cpp17Lockable*
|
| 24 |
+
requirements, and the *Cpp17TimedLockable* requirements list the
|
| 25 |
+
requirements imposed by these library types in order to acquire or
|
| 26 |
+
release ownership of a `lock` by a given execution agent.
|
| 27 |
|
| 28 |
[*Note 3*: The nature of any lock ownership and any synchronization it
|
| 29 |
+
entails are not part of these requirements. — *end note*]
|
| 30 |
|
| 31 |
+
#### *Cpp17BasicLockable* requirements <a id="thread.req.lockable.basic">[[thread.req.lockable.basic]]</a>
|
| 32 |
|
| 33 |
+
A type `L` meets the *Cpp17BasicLockable* requirements if the following
|
| 34 |
expressions are well-formed and have the specified semantics (`m`
|
| 35 |
denotes a value of type `L`).
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
m.lock()
|
|
|
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
m.unlock()
|
| 47 |
```
|
| 48 |
|
| 49 |
+
*Preconditions:* The current execution agent holds a lock on `m`.
|
| 50 |
|
| 51 |
*Effects:* Releases a lock on `m` held by the current execution agent.
|
| 52 |
|
| 53 |
*Throws:* Nothing.
|
| 54 |
|
| 55 |
+
#### *Cpp17Lockable* requirements <a id="thread.req.lockable.req">[[thread.req.lockable.req]]</a>
|
| 56 |
|
| 57 |
+
A type `L` meets the *Cpp17Lockable* requirements if it meets the
|
| 58 |
+
*Cpp17BasicLockable* requirements and the following expressions are
|
| 59 |
well-formed and have the specified semantics (`m` denotes a value of
|
| 60 |
type `L`).
|
| 61 |
|
| 62 |
``` cpp
|
| 63 |
m.try_lock()
|
|
|
|
| 69 |
|
| 70 |
*Return type:* `bool`.
|
| 71 |
|
| 72 |
*Returns:* `true` if the lock was acquired, `false` otherwise.
|
| 73 |
|
| 74 |
+
#### *Cpp17TimedLockable* requirements <a id="thread.req.lockable.timed">[[thread.req.lockable.timed]]</a>
|
| 75 |
|
| 76 |
+
A type `L` meets the *Cpp17TimedLockable* requirements if it meets the
|
| 77 |
+
*Cpp17Lockable* requirements and the following expressions are
|
| 78 |
+
well-formed and have the specified semantics (`m` denotes a value of
|
| 79 |
+
type `L`, `rel_time` denotes a value of an instantiation of `duration`
|
| 80 |
+
[[time.duration]], and `abs_time` denotes a value of an instantiation of
|
| 81 |
+
`time_point` [[time.point]]).
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
m.try_lock_for(rel_time)
|
| 85 |
```
|
| 86 |
|
| 87 |
*Effects:* Attempts to acquire a lock for the current execution agent
|
| 88 |
+
within the relative timeout [[thread.req.timing]] specified by
|
| 89 |
+
`rel_time`. The function will not return within the timeout specified by
|
| 90 |
+
`rel_time` unless it has obtained a lock on `m` for the current
|
| 91 |
+
execution agent. If an exception is thrown then a lock has not been
|
| 92 |
+
acquired for the current execution agent.
|
| 93 |
|
| 94 |
*Return type:* `bool`.
|
| 95 |
|
| 96 |
*Returns:* `true` if the lock was acquired, `false` otherwise.
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
m.try_lock_until(abs_time)
|
| 100 |
```
|
| 101 |
|
| 102 |
*Effects:* Attempts to acquire a lock for the current execution agent
|
| 103 |
+
before the absolute timeout [[thread.req.timing]] specified by
|
| 104 |
+
`abs_time`. The function will not return before the timeout specified by
|
| 105 |
+
`abs_time` unless it has obtained a lock on `m` for the current
|
| 106 |
+
execution agent. If an exception is thrown then a lock has not been
|
| 107 |
+
acquired for the current execution agent.
|
| 108 |
|
| 109 |
*Return type:* `bool`.
|
| 110 |
|
| 111 |
*Returns:* `true` if the lock was acquired, `false` otherwise.
|
| 112 |
|