Init
This commit is contained in:
45
cppdraft/thread/req/exception.md
Normal file
45
cppdraft/thread/req/exception.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[thread.req.exception]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#exception)
|
||||
|
||||
### 32.2.2 Exceptions [thread.req.exception]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L49)
|
||||
|
||||
Some functions described in this Clause are specified to throw exceptions of typesystem_error ([[syserr.syserr]](syserr.syserr "19.5.8 Class system_error"))[.](#1.sentence-1)
|
||||
|
||||
Such exceptions are thrown if
|
||||
any of the function's error conditions is detected or
|
||||
a call to
|
||||
an operating system or other underlying API results in an error that prevents the
|
||||
library function from
|
||||
meeting its specifications[.](#1.sentence-2)
|
||||
|
||||
Failure to allocate storage is reported as described
|
||||
in [[res.on.exception.handling]](res.on.exception.handling "16.4.6.14 Restrictions on exception handling")[.](#1.sentence-3)
|
||||
|
||||
[*Example [1](#example-1)*:
|
||||
|
||||
Consider a function in this Clause that is specified to throw exceptions of typesystem_error and specifies error conditions that includeoperation_not_permitted for a thread that does not have the privilege to
|
||||
perform the operation[.](#1.sentence-4)
|
||||
|
||||
Assume that, during the execution of this function, an errno of EPERM is reported by a POSIX API call used by the implementation[.](#1.sentence-5)
|
||||
|
||||
Since POSIX
|
||||
specifies an errno of EPERM when âthe caller does not have the privilege
|
||||
to perform the operationâ, the implementation maps EPERM to anerror_condition of operation_not_permitted ([[syserr]](syserr "19.5 System error support")) and an exception
|
||||
of type system_error is thrown[.](#1.sentence-6)
|
||||
|
||||
â *end example*]
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L71)
|
||||
|
||||
The error_code reported by such an exception's code() member function
|
||||
compares equal to one of the conditions specified in the function's error condition
|
||||
element[.](#2.sentence-1)
|
||||
358
cppdraft/thread/req/lockable.md
Normal file
358
cppdraft/thread/req/lockable.md
Normal file
@@ -0,0 +1,358 @@
|
||||
[thread.req.lockable]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#lockable)
|
||||
|
||||
### 32.2.5 Requirements for *Cpp17Lockable* types [thread.req.lockable]
|
||||
|
||||
#### [32.2.5.1](#general) General [[thread.req.lockable.general]](thread.req.lockable.general)
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L174)
|
||||
|
||||
An [*execution agent*](#def:execution_agent "32.2.5.1 General [thread.req.lockable.general]") is an entity such as a thread that may perform work in parallel with
|
||||
other execution agents[.](#general-1.sentence-1)
|
||||
|
||||
[*Note [1](#general-note-1)*:
|
||||
|
||||
Implementations or users can introduce other kinds of
|
||||
agents such as processes or thread-pool tasks[.](#general-1.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
The calling agent is determined by
|
||||
context, e.g., the calling thread that contains the call, and so on[.](#general-1.sentence-3)
|
||||
|
||||
[2](#general-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L184)
|
||||
|
||||
[*Note [2](#general-note-2)*:
|
||||
|
||||
Some lockable objects are âagent obliviousâ in that they work for any
|
||||
execution agent model because they do not determine or store the agent's ID (e.g., an
|
||||
ordinary spin lock)[.](#general-2.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[3](#general-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L191)
|
||||
|
||||
The standard library templates unique_lock ([[thread.lock.unique]](thread.lock.unique "32.6.5.4 Class template unique_lock")),shared_lock ([[thread.lock.shared]](thread.lock.shared "32.6.5.5 Class template shared_lock")),scoped_lock ([[thread.lock.scoped]](thread.lock.scoped "32.6.5.3 Class template scoped_lock")),lock_guard ([[thread.lock.guard]](thread.lock.guard "32.6.5.2 Class template lock_guard")), lock,try_lock ([[thread.lock.algorithm]](thread.lock.algorithm "32.6.6 Generic locking algorithms")), andcondition_variable_any ([[thread.condition.condvarany]](thread.condition.condvarany "32.7.5 Class condition_variable_any")) all operate on user-supplied
|
||||
lockable objects[.](#general-3.sentence-1)
|
||||
|
||||
The [*Cpp17BasicLockable*](#:Cpp17BasicLockable "32.2.5.2 Cpp17BasicLockable requirements [thread.req.lockable.basic]") requirements, the [*Cpp17Lockable*](#:Cpp17Lockable "32.2.5.3 Cpp17Lockable requirements [thread.req.lockable.req]") requirements,
|
||||
the [*Cpp17TimedLockable*](#:Cpp17TimedLockable "32.2.5.4 Cpp17TimedLockable requirements [thread.req.lockable.timed]") requirements,
|
||||
the [*Cpp17SharedLockable*](#:Cpp17SharedLockable "32.2.5.5 Cpp17SharedLockable requirements [thread.req.lockable.shared]") requirements, and
|
||||
the [*Cpp17SharedTimedLockable*](#:Cpp17SharedTimedLockable "32.2.5.6 Cpp17SharedTimedLockable requirements [thread.req.lockable.shared.timed]") requirements
|
||||
list the requirements imposed by these library types
|
||||
in order to acquire or release ownership of a lock by a given execution agent[.](#general-3.sentence-2)
|
||||
|
||||
[*Note [3](#general-note-3)*:
|
||||
|
||||
The nature of any lock ownership and any synchronization it entails are not part
|
||||
of these requirements[.](#general-3.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[4](#general-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L209)
|
||||
|
||||
A lock on an object m is said to be
|
||||
|
||||
- [(4.1)](#general-4.1)
|
||||
|
||||
a [*non-shared lock*](#def:lock,non-shared "32.2.5.1 General [thread.req.lockable.general]") if it is acquired by a call tolock,try_lock,try_lock_for, ortry_lock_until on m, or
|
||||
|
||||
- [(4.2)](#general-4.2)
|
||||
|
||||
a [*shared lock*](#def:lock,shared "32.2.5.1 General [thread.req.lockable.general]") if it is acquired by a call tolock_shared,try_lock_shared,try_lock_shared_for, ortry_lock_shared_until on m[.](#general-4.sentence-1)
|
||||
|
||||
[*Note [4](#general-note-4)*:
|
||||
|
||||
Only the method of lock acquisition is considered;
|
||||
the nature of any lock ownership is not part of these definitions[.](#general-4.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
#### [32.2.5.2](#basic) *Cpp17BasicLockable* requirements [[thread.req.lockable.basic]](thread.req.lockable.basic)
|
||||
|
||||
[1](#basic-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L232)
|
||||
|
||||
A type L meets the *Cpp17BasicLockable* requirements if the following expressions are
|
||||
well-formed and have the specified semantics (m denotes a value of type L)[.](#basic-1.sentence-1)
|
||||
|
||||
[ð](#basic-itemdecl:1)
|
||||
|
||||
`m.lock()
|
||||
`
|
||||
|
||||
[2](#basic-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L241)
|
||||
|
||||
*Effects*: Blocks until a lock can be acquired for the current execution agent[.](#basic-2.sentence-1)
|
||||
|
||||
If an exception
|
||||
is thrown then a lock shall not have been acquired for the current execution agent[.](#basic-2.sentence-2)
|
||||
|
||||
[ð](#basic-itemdecl:2)
|
||||
|
||||
`m.unlock()
|
||||
`
|
||||
|
||||
[3](#basic-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L253)
|
||||
|
||||
*Preconditions*: The current execution agent holds a non-shared lock on m[.](#basic-3.sentence-1)
|
||||
|
||||
[4](#basic-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L257)
|
||||
|
||||
*Effects*: Releases a non-shared lock on m held by the current execution agent[.](#basic-4.sentence-1)
|
||||
|
||||
[5](#basic-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L261)
|
||||
|
||||
*Throws*: Nothing[.](#basic-5.sentence-1)
|
||||
|
||||
#### [32.2.5.3](#req) *Cpp17Lockable* requirements [[thread.req.lockable.req]](thread.req.lockable.req)
|
||||
|
||||
[1](#req-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L268)
|
||||
|
||||
A type L meets the *Cpp17Lockable* requirements if it meets the [*Cpp17BasicLockable*](#:Cpp17BasicLockable "32.2.5.2 Cpp17BasicLockable requirements [thread.req.lockable.basic]") requirements and the following expressions are well-formed and have the specified semantics
|
||||
(m denotes a value of type L)[.](#req-1.sentence-1)
|
||||
|
||||
[ð](#req-itemdecl:1)
|
||||
|
||||
`m.try_lock()
|
||||
`
|
||||
|
||||
[2](#req-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L278)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent without blocking[.](#req-2.sentence-1)
|
||||
|
||||
If an
|
||||
exception is thrown then a lock shall not have been acquired for the current execution agent[.](#req-2.sentence-2)
|
||||
|
||||
[3](#req-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L283)
|
||||
|
||||
*Return type*: bool[.](#req-3.sentence-1)
|
||||
|
||||
[4](#req-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L286)
|
||||
|
||||
*Returns*: true if the lock was acquired, otherwise false[.](#req-4.sentence-1)
|
||||
|
||||
#### [32.2.5.4](#timed) *Cpp17TimedLockable* requirements [[thread.req.lockable.timed]](thread.req.lockable.timed)
|
||||
|
||||
[1](#timed-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L293)
|
||||
|
||||
A type L meets the *Cpp17TimedLockable* requirements if it meets the [*Cpp17Lockable*](#:Cpp17Lockable "32.2.5.3 Cpp17Lockable requirements [thread.req.lockable.req]") requirements and the following expressions are well-formed and have the specified semantics
|
||||
(m denotes a value of type L, rel_time denotes a value of an
|
||||
instantiation of [duration](time.duration "30.5 Class template duration [time.duration]"), and abs_time denotes a value
|
||||
of an instantiation of [time_point](time.point "30.6 Class template time_point [time.point]"))[.](#timed-1.sentence-1)
|
||||
|
||||
[ð](#timed-itemdecl:1)
|
||||
|
||||
`m.try_lock_for(rel_time)
|
||||
`
|
||||
|
||||
[2](#timed-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L305)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent within the relative
|
||||
timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by rel_time[.](#timed-2.sentence-1)
|
||||
|
||||
The function will not return
|
||||
within the timeout specified by rel_time unless it has obtained a lock on m for the current execution agent[.](#timed-2.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been
|
||||
acquired for the current execution agent[.](#timed-2.sentence-3)
|
||||
|
||||
[3](#timed-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L313)
|
||||
|
||||
*Return type*: bool[.](#timed-3.sentence-1)
|
||||
|
||||
[4](#timed-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L316)
|
||||
|
||||
*Returns*: true if the lock was acquired, otherwise false[.](#timed-4.sentence-1)
|
||||
|
||||
[ð](#timed-itemdecl:2)
|
||||
|
||||
`m.try_lock_until(abs_time)
|
||||
`
|
||||
|
||||
[5](#timed-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L326)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent before the absolute
|
||||
timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by abs_time[.](#timed-5.sentence-1)
|
||||
|
||||
The function will not return
|
||||
before the timeout specified by abs_time unless it has obtained a lock on m for
|
||||
the current execution agent[.](#timed-5.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been acquired
|
||||
for the current execution agent[.](#timed-5.sentence-3)
|
||||
|
||||
[6](#timed-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L334)
|
||||
|
||||
*Return type*: bool[.](#timed-6.sentence-1)
|
||||
|
||||
[7](#timed-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L337)
|
||||
|
||||
*Returns*: true if the lock was acquired, otherwise false[.](#timed-7.sentence-1)
|
||||
|
||||
#### [32.2.5.5](#shared) *Cpp17SharedLockable* requirements [[thread.req.lockable.shared]](thread.req.lockable.shared)
|
||||
|
||||
[1](#shared-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L344)
|
||||
|
||||
A type L meets the *Cpp17SharedLockable* requirements if
|
||||
the following expressions are well-formed, have the specified semantics, and
|
||||
the expression m.try_lock_shared() has type bool (m denotes a value of type L):
|
||||
|
||||
[ð](#shared-itemdecl:1)
|
||||
|
||||
`m.lock_shared()
|
||||
`
|
||||
|
||||
[2](#shared-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L355)
|
||||
|
||||
*Effects*: Blocks until a lock can be acquired for the current execution agent[.](#shared-2.sentence-1)
|
||||
|
||||
If an exception is thrown then a lock shall not have been acquired for
|
||||
the current execution agent[.](#shared-2.sentence-2)
|
||||
|
||||
[ð](#shared-itemdecl:2)
|
||||
|
||||
`m.try_lock_shared()
|
||||
`
|
||||
|
||||
[3](#shared-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L367)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent without blocking[.](#shared-3.sentence-1)
|
||||
|
||||
If an exception is thrown then a lock shall not have been acquired for
|
||||
the current execution agent[.](#shared-3.sentence-2)
|
||||
|
||||
[4](#shared-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L373)
|
||||
|
||||
*Returns*: true if the lock was acquired, false otherwise[.](#shared-4.sentence-1)
|
||||
|
||||
[ð](#shared-itemdecl:3)
|
||||
|
||||
`m.unlock_shared()
|
||||
`
|
||||
|
||||
[5](#shared-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L383)
|
||||
|
||||
*Preconditions*: The current execution agent holds a shared lock on m[.](#shared-5.sentence-1)
|
||||
|
||||
[6](#shared-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L387)
|
||||
|
||||
*Effects*: Releases a shared lock on m held by the current execution agent[.](#shared-6.sentence-1)
|
||||
|
||||
[7](#shared-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L391)
|
||||
|
||||
*Throws*: Nothing[.](#shared-7.sentence-1)
|
||||
|
||||
#### [32.2.5.6](#shared.timed) *Cpp17SharedTimedLockable* requirements [[thread.req.lockable.shared.timed]](thread.req.lockable.shared.timed)
|
||||
|
||||
[1](#shared.timed-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L398)
|
||||
|
||||
A type L meets the *Cpp17SharedTimedLockable* requirements if
|
||||
it meets the [*Cpp17SharedLockable*](#:Cpp17SharedLockable "32.2.5.5 Cpp17SharedLockable requirements [thread.req.lockable.shared]") requirements, and
|
||||
the following expressions are well-formed, have type bool, and
|
||||
have the specified semantics
|
||||
(m denotes a value of type L,rel_time denotes a value of a specialization of chrono::duration, andabs_time denotes a value of a specialization of chrono::time_point)[.](#shared.timed-1.sentence-1)
|
||||
|
||||
[ð](#shared.timed-itemdecl:1)
|
||||
|
||||
`m.try_lock_shared_for(rel_time)
|
||||
`
|
||||
|
||||
[2](#shared.timed-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L412)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent within
|
||||
the relative timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by rel_time[.](#shared.timed-2.sentence-1)
|
||||
|
||||
The function will not return within the timeout specified by rel_time unless it has obtained a lock on m for the current execution agent[.](#shared.timed-2.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been acquired for
|
||||
the current execution agent[.](#shared.timed-2.sentence-3)
|
||||
|
||||
[3](#shared.timed-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L421)
|
||||
|
||||
*Returns*: true if the lock was acquired, false otherwise[.](#shared.timed-3.sentence-1)
|
||||
|
||||
[ð](#shared.timed-itemdecl:2)
|
||||
|
||||
`m.try_lock_shared_until(abs_time)
|
||||
`
|
||||
|
||||
[4](#shared.timed-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L431)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent before
|
||||
the absolute timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by abs_time[.](#shared.timed-4.sentence-1)
|
||||
|
||||
The function will not return before the timeout specified by abs_time unless it has obtained a lock on m for the current execution agent[.](#shared.timed-4.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been acquired for
|
||||
the current execution agent[.](#shared.timed-4.sentence-3)
|
||||
|
||||
[5](#shared.timed-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L440)
|
||||
|
||||
*Returns*: true if the lock was acquired, false otherwise[.](#shared.timed-5.sentence-1)
|
||||
53
cppdraft/thread/req/lockable/basic.md
Normal file
53
cppdraft/thread/req/lockable/basic.md
Normal file
@@ -0,0 +1,53 @@
|
||||
[thread.req.lockable.basic]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#lockable.basic)
|
||||
|
||||
### 32.2.5 Requirements for *Cpp17Lockable* types [[thread.req.lockable]](thread.req.lockable#basic)
|
||||
|
||||
#### 32.2.5.2 *Cpp17BasicLockable* requirements [thread.req.lockable.basic]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L232)
|
||||
|
||||
A type L meets the *Cpp17BasicLockable* requirements if the following expressions are
|
||||
well-formed and have the specified semantics (m denotes a value of type L)[.](#1.sentence-1)
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`m.lock()
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L241)
|
||||
|
||||
*Effects*: Blocks until a lock can be acquired for the current execution agent[.](#2.sentence-1)
|
||||
|
||||
If an exception
|
||||
is thrown then a lock shall not have been acquired for the current execution agent[.](#2.sentence-2)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`m.unlock()
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L253)
|
||||
|
||||
*Preconditions*: The current execution agent holds a non-shared lock on m[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L257)
|
||||
|
||||
*Effects*: Releases a non-shared lock on m held by the current execution agent[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L261)
|
||||
|
||||
*Throws*: Nothing[.](#5.sentence-1)
|
||||
80
cppdraft/thread/req/lockable/general.md
Normal file
80
cppdraft/thread/req/lockable/general.md
Normal file
@@ -0,0 +1,80 @@
|
||||
[thread.req.lockable.general]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#lockable.general)
|
||||
|
||||
### 32.2.5 Requirements for *Cpp17Lockable* types [[thread.req.lockable]](thread.req.lockable#general)
|
||||
|
||||
#### 32.2.5.1 General [thread.req.lockable.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L174)
|
||||
|
||||
An [*execution agent*](#def:execution_agent "32.2.5.1 General [thread.req.lockable.general]") is an entity such as a thread that may perform work in parallel with
|
||||
other execution agents[.](#1.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
Implementations or users can introduce other kinds of
|
||||
agents such as processes or thread-pool tasks[.](#1.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
The calling agent is determined by
|
||||
context, e.g., the calling thread that contains the call, and so on[.](#1.sentence-3)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L184)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
Some lockable objects are âagent obliviousâ in that they work for any
|
||||
execution agent model because they do not determine or store the agent's ID (e.g., an
|
||||
ordinary spin lock)[.](#2.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L191)
|
||||
|
||||
The standard library templates unique_lock ([[thread.lock.unique]](thread.lock.unique "32.6.5.4 Class template unique_lock")),shared_lock ([[thread.lock.shared]](thread.lock.shared "32.6.5.5 Class template shared_lock")),scoped_lock ([[thread.lock.scoped]](thread.lock.scoped "32.6.5.3 Class template scoped_lock")),lock_guard ([[thread.lock.guard]](thread.lock.guard "32.6.5.2 Class template lock_guard")), lock,try_lock ([[thread.lock.algorithm]](thread.lock.algorithm "32.6.6 Generic locking algorithms")), andcondition_variable_any ([[thread.condition.condvarany]](thread.condition.condvarany "32.7.5 Class condition_variable_any")) all operate on user-supplied
|
||||
lockable objects[.](#3.sentence-1)
|
||||
|
||||
The [*Cpp17BasicLockable*](thread.req.lockable.basic#:Cpp17BasicLockable "32.2.5.2 Cpp17BasicLockable requirements [thread.req.lockable.basic]") requirements, the [*Cpp17Lockable*](thread.req.lockable.req#:Cpp17Lockable "32.2.5.3 Cpp17Lockable requirements [thread.req.lockable.req]") requirements,
|
||||
the [*Cpp17TimedLockable*](thread.req.lockable.timed#:Cpp17TimedLockable "32.2.5.4 Cpp17TimedLockable requirements [thread.req.lockable.timed]") requirements,
|
||||
the [*Cpp17SharedLockable*](thread.req.lockable.shared#:Cpp17SharedLockable "32.2.5.5 Cpp17SharedLockable requirements [thread.req.lockable.shared]") requirements, and
|
||||
the [*Cpp17SharedTimedLockable*](thread.req.lockable.shared.timed#:Cpp17SharedTimedLockable "32.2.5.6 Cpp17SharedTimedLockable requirements [thread.req.lockable.shared.timed]") requirements
|
||||
list the requirements imposed by these library types
|
||||
in order to acquire or release ownership of a lock by a given execution agent[.](#3.sentence-2)
|
||||
|
||||
[*Note [3](#note-3)*:
|
||||
|
||||
The nature of any lock ownership and any synchronization it entails are not part
|
||||
of these requirements[.](#3.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L209)
|
||||
|
||||
A lock on an object m is said to be
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
a [*non-shared lock*](#def:lock,non-shared "32.2.5.1 General [thread.req.lockable.general]") if it is acquired by a call tolock,try_lock,try_lock_for, ortry_lock_until on m, or
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
a [*shared lock*](#def:lock,shared "32.2.5.1 General [thread.req.lockable.general]") if it is acquired by a call tolock_shared,try_lock_shared,try_lock_shared_for, ortry_lock_shared_until on m[.](#4.sentence-1)
|
||||
|
||||
[*Note [4](#note-4)*:
|
||||
|
||||
Only the method of lock acquisition is considered;
|
||||
the nature of any lock ownership is not part of these definitions[.](#4.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
42
cppdraft/thread/req/lockable/req.md
Normal file
42
cppdraft/thread/req/lockable/req.md
Normal file
@@ -0,0 +1,42 @@
|
||||
[thread.req.lockable.req]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#lockable.req)
|
||||
|
||||
### 32.2.5 Requirements for *Cpp17Lockable* types [[thread.req.lockable]](thread.req.lockable#req)
|
||||
|
||||
#### 32.2.5.3 *Cpp17Lockable* requirements [thread.req.lockable.req]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L268)
|
||||
|
||||
A type L meets the *Cpp17Lockable* requirements if it meets the [*Cpp17BasicLockable*](thread.req.lockable.basic#:Cpp17BasicLockable "32.2.5.2 Cpp17BasicLockable requirements [thread.req.lockable.basic]") requirements and the following expressions are well-formed and have the specified semantics
|
||||
(m denotes a value of type L)[.](#1.sentence-1)
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`m.try_lock()
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L278)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent without blocking[.](#2.sentence-1)
|
||||
|
||||
If an
|
||||
exception is thrown then a lock shall not have been acquired for the current execution agent[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L283)
|
||||
|
||||
*Return type*: bool[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L286)
|
||||
|
||||
*Returns*: true if the lock was acquired, otherwise false[.](#4.sentence-1)
|
||||
74
cppdraft/thread/req/lockable/shared.md
Normal file
74
cppdraft/thread/req/lockable/shared.md
Normal file
@@ -0,0 +1,74 @@
|
||||
[thread.req.lockable.shared]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#lockable.shared)
|
||||
|
||||
### 32.2.5 Requirements for *Cpp17Lockable* types [[thread.req.lockable]](thread.req.lockable#shared)
|
||||
|
||||
#### 32.2.5.5 *Cpp17SharedLockable* requirements [thread.req.lockable.shared]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L344)
|
||||
|
||||
A type L meets the *Cpp17SharedLockable* requirements if
|
||||
the following expressions are well-formed, have the specified semantics, and
|
||||
the expression m.try_lock_shared() has type bool (m denotes a value of type L):
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`m.lock_shared()
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L355)
|
||||
|
||||
*Effects*: Blocks until a lock can be acquired for the current execution agent[.](#2.sentence-1)
|
||||
|
||||
If an exception is thrown then a lock shall not have been acquired for
|
||||
the current execution agent[.](#2.sentence-2)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`m.try_lock_shared()
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L367)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent without blocking[.](#3.sentence-1)
|
||||
|
||||
If an exception is thrown then a lock shall not have been acquired for
|
||||
the current execution agent[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L373)
|
||||
|
||||
*Returns*: true if the lock was acquired, false otherwise[.](#4.sentence-1)
|
||||
|
||||
[ð](#itemdecl:3)
|
||||
|
||||
`m.unlock_shared()
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L383)
|
||||
|
||||
*Preconditions*: The current execution agent holds a shared lock on m[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L387)
|
||||
|
||||
*Effects*: Releases a shared lock on m held by the current execution agent[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L391)
|
||||
|
||||
*Throws*: Nothing[.](#7.sentence-1)
|
||||
65
cppdraft/thread/req/lockable/shared/timed.md
Normal file
65
cppdraft/thread/req/lockable/shared/timed.md
Normal file
@@ -0,0 +1,65 @@
|
||||
[thread.req.lockable.shared.timed]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#lockable.shared.timed)
|
||||
|
||||
### 32.2.5 Requirements for *Cpp17Lockable* types [[thread.req.lockable]](thread.req.lockable#shared.timed)
|
||||
|
||||
#### 32.2.5.6 *Cpp17SharedTimedLockable* requirements [thread.req.lockable.shared.timed]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L398)
|
||||
|
||||
A type L meets the *Cpp17SharedTimedLockable* requirements if
|
||||
it meets the [*Cpp17SharedLockable*](thread.req.lockable.shared#:Cpp17SharedLockable "32.2.5.5 Cpp17SharedLockable requirements [thread.req.lockable.shared]") requirements, and
|
||||
the following expressions are well-formed, have type bool, and
|
||||
have the specified semantics
|
||||
(m denotes a value of type L,rel_time denotes a value of a specialization of chrono::duration, andabs_time denotes a value of a specialization of chrono::time_point)[.](#1.sentence-1)
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`m.try_lock_shared_for(rel_time)
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L412)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent within
|
||||
the relative timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by rel_time[.](#2.sentence-1)
|
||||
|
||||
The function will not return within the timeout specified by rel_time unless it has obtained a lock on m for the current execution agent[.](#2.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been acquired for
|
||||
the current execution agent[.](#2.sentence-3)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L421)
|
||||
|
||||
*Returns*: true if the lock was acquired, false otherwise[.](#3.sentence-1)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`m.try_lock_shared_until(abs_time)
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L431)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent before
|
||||
the absolute timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by abs_time[.](#4.sentence-1)
|
||||
|
||||
The function will not return before the timeout specified by abs_time unless it has obtained a lock on m for the current execution agent[.](#4.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been acquired for
|
||||
the current execution agent[.](#4.sentence-3)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L440)
|
||||
|
||||
*Returns*: true if the lock was acquired, false otherwise[.](#5.sentence-1)
|
||||
79
cppdraft/thread/req/lockable/timed.md
Normal file
79
cppdraft/thread/req/lockable/timed.md
Normal file
@@ -0,0 +1,79 @@
|
||||
[thread.req.lockable.timed]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#lockable.timed)
|
||||
|
||||
### 32.2.5 Requirements for *Cpp17Lockable* types [[thread.req.lockable]](thread.req.lockable#timed)
|
||||
|
||||
#### 32.2.5.4 *Cpp17TimedLockable* requirements [thread.req.lockable.timed]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L293)
|
||||
|
||||
A type L meets the *Cpp17TimedLockable* requirements if it meets the [*Cpp17Lockable*](thread.req.lockable.req#:Cpp17Lockable "32.2.5.3 Cpp17Lockable requirements [thread.req.lockable.req]") requirements and the following expressions are well-formed and have the specified semantics
|
||||
(m denotes a value of type L, rel_time denotes a value of an
|
||||
instantiation of [duration](time.duration "30.5 Class template duration [time.duration]"), and abs_time denotes a value
|
||||
of an instantiation of [time_point](time.point "30.6 Class template time_point [time.point]"))[.](#1.sentence-1)
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`m.try_lock_for(rel_time)
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L305)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent within the relative
|
||||
timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by rel_time[.](#2.sentence-1)
|
||||
|
||||
The function will not return
|
||||
within the timeout specified by rel_time unless it has obtained a lock on m for the current execution agent[.](#2.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been
|
||||
acquired for the current execution agent[.](#2.sentence-3)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L313)
|
||||
|
||||
*Return type*: bool[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L316)
|
||||
|
||||
*Returns*: true if the lock was acquired, otherwise false[.](#4.sentence-1)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`m.try_lock_until(abs_time)
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L326)
|
||||
|
||||
*Effects*: Attempts to acquire a lock for the current execution agent before the absolute
|
||||
timeout ([[thread.req.timing]](thread.req.timing "32.2.4 Timing specifications")) specified by abs_time[.](#5.sentence-1)
|
||||
|
||||
The function will not return
|
||||
before the timeout specified by abs_time unless it has obtained a lock on m for
|
||||
the current execution agent[.](#5.sentence-2)
|
||||
|
||||
If an exception is thrown then a lock has not been acquired
|
||||
for the current execution agent[.](#5.sentence-3)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L334)
|
||||
|
||||
*Return type*: bool[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L337)
|
||||
|
||||
*Returns*: true if the lock was acquired, otherwise false[.](#7.sentence-1)
|
||||
27
cppdraft/thread/req/native.md
Normal file
27
cppdraft/thread/req/native.md
Normal file
@@ -0,0 +1,27 @@
|
||||
[thread.req.native]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#native)
|
||||
|
||||
### 32.2.3 Native handles [thread.req.native]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L78)
|
||||
|
||||
Several classes described in this Clause have members native_handle_type andnative_handle[.](#1.sentence-1)
|
||||
|
||||
The presence of these members and their semantics isimplementation-defined[.](#1.sentence-2)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
These members allow implementations to provide access
|
||||
to implementation details[.](#1.sentence-3)
|
||||
|
||||
Their names are specified to facilitate portable compile-time
|
||||
detection[.](#1.sentence-4)
|
||||
|
||||
Actual use of these members is inherently non-portable[.](#1.sentence-5)
|
||||
|
||||
â *end note*]
|
||||
28
cppdraft/thread/req/paramname.md
Normal file
28
cppdraft/thread/req/paramname.md
Normal file
@@ -0,0 +1,28 @@
|
||||
[thread.req.paramname]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#paramname)
|
||||
|
||||
### 32.2.1 Template parameter names [thread.req.paramname]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L31)
|
||||
|
||||
Throughout this Clause, the names of template parameters are used to express type
|
||||
requirements[.](#1.sentence-1)
|
||||
|
||||
Predicate is a function object type ([[function.objects]](function.objects "22.10 Function objects"))[.](#1.sentence-2)
|
||||
|
||||
Let pred denote an lvalue of type Predicate[.](#1.sentence-3)
|
||||
|
||||
Then the expression pred() shall be well-formed and
|
||||
the type decltype(pred()) shall model[*boolean-testable*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]") ([[concept.booleantestable]](concept.booleantestable "18.5.2 Boolean testability"))[.](#1.sentence-4)
|
||||
|
||||
The return value of pred(), converted to bool,
|
||||
yields true if the corresponding test condition is satisfied, andfalse otherwise[.](#1.sentence-5)
|
||||
|
||||
If a template parameter is named Clock,
|
||||
the corresponding template argument shall be a type C that meets the [*Cpp17Clock*](time.clock.req#:Cpp17Clock "30.3 Cpp17Clock requirements [time.clock.req]") requirements ([[time.clock.req]](time.clock.req "30.3 Cpp17Clock requirements"));
|
||||
the program is ill-formed if is_clock_v<C> is false[.](#1.sentence-6)
|
||||
138
cppdraft/thread/req/timing.md
Normal file
138
cppdraft/thread/req/timing.md
Normal file
@@ -0,0 +1,138 @@
|
||||
[thread.req.timing]
|
||||
|
||||
# 32 Concurrency support library [[thread]](./#thread)
|
||||
|
||||
## 32.2 Requirements [[thread.req]](thread.req#timing)
|
||||
|
||||
### 32.2.4 Timing specifications [thread.req.timing]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L90)
|
||||
|
||||
Several functions described in this Clause take an argument to specify a timeout[.](#1.sentence-1)
|
||||
|
||||
These
|
||||
timeouts are specified as either a duration or a time_point type as
|
||||
specified in [[time]](time "30 Time library")[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L95)
|
||||
|
||||
Implementations necessarily have some delay in returning from a timeout[.](#2.sentence-1)
|
||||
|
||||
Any overhead in
|
||||
interrupt response, function return, and scheduling induces a âquality of implementationâ
|
||||
delay, expressed as duration Di[.](#2.sentence-2)
|
||||
|
||||
Ideally, this delay would be zero[.](#2.sentence-3)
|
||||
|
||||
Further, any contention for
|
||||
processor and memory resources induces a âquality of managementâ delay, expressed as durationDm[.](#2.sentence-4)
|
||||
|
||||
The delay durations may vary from timeout to timeout, but in all cases shorter is better[.](#2.sentence-5)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L102)
|
||||
|
||||
The functions whose names end in _for take an argument that
|
||||
specifies a duration[.](#3.sentence-1)
|
||||
|
||||
These functions produce relative timeouts[.](#3.sentence-2)
|
||||
|
||||
Implementations
|
||||
should use a steady clock to measure time for these functions[.](#3.sentence-3)[293](#footnote-293 "Implementations for which standard time units are meaningful will typically have a steady clock within their hardware implementation.")
|
||||
|
||||
Given a duration
|
||||
argument Dt, the real-time duration of the timeout is Dt+Di+Dm[.](#3.sentence-4)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L113)
|
||||
|
||||
The functions whose names end in _until take an argument that specifies a time
|
||||
point[.](#4.sentence-1)
|
||||
|
||||
These functions produce absolute timeouts[.](#4.sentence-2)
|
||||
|
||||
Implementations should use the clock
|
||||
specified in the time point to measure time for these functions[.](#4.sentence-3)
|
||||
|
||||
Given a clock time point
|
||||
argument Ct, the clock time point of the return from timeout should be Ct+Di+Dm when the clock is not adjusted during the timeout[.](#4.sentence-4)
|
||||
|
||||
If the clock is adjusted to the time Ca during the timeout, the behavior should be as follows:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
If Ca>Ct, the waiting function should wake as soon as possible, i.e., Ca+Di+Dm,
|
||||
since the timeout is already satisfied[.](#4.1.sentence-1)
|
||||
This specification may result in the total
|
||||
duration of the wait decreasing when measured against a steady clock[.](#4.1.sentence-2)
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
If Caâ¤Ct, the waiting function should not time out until Clock::now() returns a
|
||||
time Cnâ¥Ct, i.e., waking at Ct+Di+Dm[.](#4.2.sentence-1)
|
||||
[*Note [1](#note-1)*:
|
||||
When the clock is adjusted
|
||||
backwards, this specification can result in the total duration of the wait increasing when
|
||||
measured against a steady clock[.](#4.2.sentence-2)
|
||||
When the clock is adjusted forwards, this specification can
|
||||
result in the total duration of the wait decreasing when measured against a steady clock[.](#4.2.sentence-3)
|
||||
â *end note*]
|
||||
|
||||
An implementation returns from such a timeout at any point from the time specified above to
|
||||
the time it would return from a steady-clock relative timeout on the difference between Ct and the time point of the call to the _until function[.](#4.sentence-6)
|
||||
|
||||
*Recommended practice*: Implementations
|
||||
should decrease the duration of the wait when the clock is adjusted forwards[.](#4.sentence-7)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L146)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
If the clock is not synchronized with a steady clock, e.g., a CPU time clock, these
|
||||
timeouts can fail to provide useful functionality[.](#5.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L152)
|
||||
|
||||
The resolution of timing provided by an implementation depends on both operating system
|
||||
and hardware[.](#6.sentence-1)
|
||||
|
||||
The finest resolution provided by an implementation is called the[*native resolution*](#def:native_resolution)[.](#6.sentence-2)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L157)
|
||||
|
||||
Implementation-provided clocks that are used for these functions meet the[*Cpp17TrivialClock*](time.clock.req#:Cpp17TrivialClock "30.3 Cpp17Clock requirements [time.clock.req]") requirements ([[time.clock.req]](time.clock.req "30.3 Cpp17Clock requirements"))[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L161)
|
||||
|
||||
A function that takes an argument which specifies a timeout will throw if,
|
||||
during its execution, a clock, time point, or time duration throws an exception[.](#8.sentence-1)
|
||||
|
||||
Such exceptions are referred to as [*timeout-related exceptions*](#def:timeout-related_exceptions)[.](#8.sentence-2)
|
||||
|
||||
[*Note [3](#note-3)*:
|
||||
|
||||
Instantiations of clock, time point and duration types supplied by
|
||||
the implementation as specified in [[time.clock]](time.clock "30.7 Clocks") do not throw exceptions[.](#8.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[293)](#footnote-293)[293)](#footnoteref-293)
|
||||
|
||||
Implementations for which standard time units are meaningful will typically
|
||||
have a steady clock within their hardware implementation[.](#footnote-293.sentence-1)
|
||||
Reference in New Issue
Block a user