tmp/tmpuucmldjg/{from.md → to.md}
RENAMED
|
@@ -1,28 +1,34 @@
|
|
| 1 |
-
### Requirements for Lockable 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 |
The calling agent is determined by context, e.g. the calling thread that
|
| 9 |
contains the call, and so on.
|
| 10 |
|
| 11 |
-
Some lockable objects are “agent oblivious” in that they
|
| 12 |
-
execution agent model because they do not determine or
|
| 13 |
-
ID (e.g., an ordinary spin lock).
|
| 14 |
|
| 15 |
The standard library templates `unique_lock` ([[thread.lock.unique]]),
|
| 16 |
-
`
|
| 17 |
-
[[thread.lock.
|
|
|
|
| 18 |
[[thread.condition.condvarany]]) all operate on user-supplied lockable
|
| 19 |
objects. The `BasicLockable` requirements, the `Lockable` requirements,
|
| 20 |
and the `TimedLockable` requirements list the requirements imposed by
|
| 21 |
these library types in order to acquire or release ownership of a `lock`
|
| 22 |
-
by a given execution agent.
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
|
| 25 |
#### `BasicLockable` requirements <a id="thread.req.lockable.basic">[[thread.req.lockable.basic]]</a>
|
| 26 |
|
| 27 |
A type `L` meets the `BasicLockable` requirements if the following
|
| 28 |
expressions are well-formed and have the specified semantics (`m`
|
|
@@ -55,11 +61,11 @@ type `L`).
|
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
m.try_lock()
|
| 58 |
```
|
| 59 |
|
| 60 |
-
*Effects:*
|
| 61 |
without blocking. If an exception is thrown then a lock shall not have
|
| 62 |
been acquired for the current execution agent.
|
| 63 |
|
| 64 |
*Return type:* `bool`.
|
| 65 |
|
|
@@ -76,11 +82,11 @@ of `time_point` ([[time.point]])).
|
|
| 76 |
|
| 77 |
``` cpp
|
| 78 |
m.try_lock_for(rel_time)
|
| 79 |
```
|
| 80 |
|
| 81 |
-
*Effects:*
|
| 82 |
within the relative timeout ([[thread.req.timing]]) specified by
|
| 83 |
`rel_time`. The function shall not return within the timeout specified
|
| 84 |
by `rel_time` unless it has obtained a lock on `m` for the current
|
| 85 |
execution agent. If an exception is thrown then a lock shall not have
|
| 86 |
been acquired for the current execution agent.
|
|
@@ -91,11 +97,11 @@ been acquired for the current execution agent.
|
|
| 91 |
|
| 92 |
``` cpp
|
| 93 |
m.try_lock_until(abs_time)
|
| 94 |
```
|
| 95 |
|
| 96 |
-
*Effects:*
|
| 97 |
before the absolute timeout ([[thread.req.timing]]) specified by
|
| 98 |
`abs_time`. The function shall not return before the timeout specified
|
| 99 |
by `abs_time` unless it has obtained a lock on `m` for the current
|
| 100 |
execution agent. If an exception is thrown then a lock shall not have
|
| 101 |
been acquired for the current execution agent.
|
|
|
|
| 1 |
+
### Requirements for `Lockable` 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 may 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 that
|
| 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` ([[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 `BasicLockable` requirements, the `Lockable` requirements,
|
| 24 |
and the `TimedLockable` requirements list the requirements imposed by
|
| 25 |
these library types in order to acquire or release ownership of a `lock`
|
| 26 |
+
by a given execution agent.
|
| 27 |
+
|
| 28 |
+
[*Note 3*: The nature of any lock ownership and any synchronization it
|
| 29 |
+
may entail are not part of these requirements. — *end note*]
|
| 30 |
|
| 31 |
#### `BasicLockable` requirements <a id="thread.req.lockable.basic">[[thread.req.lockable.basic]]</a>
|
| 32 |
|
| 33 |
A type `L` meets the `BasicLockable` requirements if the following
|
| 34 |
expressions are well-formed and have the specified semantics (`m`
|
|
|
|
| 61 |
|
| 62 |
``` cpp
|
| 63 |
m.try_lock()
|
| 64 |
```
|
| 65 |
|
| 66 |
+
*Effects:* Attempts to acquire a lock for the current execution agent
|
| 67 |
without blocking. If an exception is thrown then a lock shall not have
|
| 68 |
been acquired for the current execution agent.
|
| 69 |
|
| 70 |
*Return type:* `bool`.
|
| 71 |
|
|
|
|
| 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 shall not return within the timeout specified
|
| 90 |
by `rel_time` unless it has obtained a lock on `m` for the current
|
| 91 |
execution agent. If an exception is thrown then a lock shall not have
|
| 92 |
been acquired for the current execution agent.
|
|
|
|
| 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 shall not return before the timeout specified
|
| 105 |
by `abs_time` unless it has obtained a lock on `m` for the current
|
| 106 |
execution agent. If an exception is thrown then a lock shall not have
|
| 107 |
been acquired for the current execution agent.
|