Section: 32.6.4.5.2 [thread.sharedtimedmutex.class] Status: Resolved Submitter: Richard Smith Opened: 2014-02-16 Last modified: 2021-05-18
Priority: 2
View all issues with Resolved status.
Discussion:
32.6.4.5.2 [thread.sharedtimedmutex.class] paragraph 2:
The class
shared_timed_mutex
shall satisfy all of theSharedTimedMutex
requirements (30.4.1.4). It shall be a standard layout class (Clause 9).
There's no SharedTimedMutex
requirements; this name doesn't appear anywhere else in the standard. (Prior to N3891,
this was SharedMutex
, which was equally undefined.)
SharedMutex
or
SharedTimedMutex
were defined it could be reused here).
[2014-05-22, Daniel comments]
As for SharedTimedMutex
, there exists a similar problem in regard to TimedMutex
referred to in
32.6.4.3.2 [thread.timedmutex.class] p2 and in 32.6.4.3.3 [thread.timedmutex.recursive] p2, but nowhere defined.
mutex
shall satisfy all the
Mutex
requirements (32.6.4 [thread.mutex.requirements]).", but there are no concrete Mutex
requirements,
32.6.4 [thread.mutex.requirements] — titled as "Mutex requirements" — describes mutex types,
timed mutex types, and shared timed mutex types.
[2014-06-08, Daniel comments and provides wording]
The presented wording adds to the existing mutex types, timed mutex types, and shared timed mutex types
terms a new set of corresponding MutexType
, TimedMutexType
, and SharedTimedMutexType
requirements.
Lockable
requirements, which are not restricted to a explicitly enumerated set of library types). Second, using
**MutexType
over **Mutex
provides the additional advantage that it reduces the chances of confusing named
requirements from template parameters named Mutex
(such as for unique_lock
or shared_lock
).
Nonetheless the here presented wording has one unfortunate side-effect: Once applied it would have the effect that types
used to instantiate std::shared_lock
cannot be user-defined shared mutex types due to 32.6.5.5 [thread.lock.shared].
The reason is based on the currently lack of an existing SharedLockable
requirement set, which would complete the
existing BasicLockable
and Lockable
requirements (which are "real" requirements). This restriction is not
actually a problem introduced by the provided resolution but instead one that existed before but becomes more obvious now.
[2015-02 Cologne]
Handed over to SG1.
[2015-05 Lenexa, SG1 response]
Thanks to Daniel, and please put it in SG1-OK status. Perhaps open another issue for the remaining problem Daniel points out?
[2015-10 pre-Kona]
SG1 hands this over to LWG for wording review
[2015-10-21 Kona, Daniel comments and adjusts wording to to untimed shared mutex types]
The new wording reflects the addition of the new shared mutex types. The approach used for shared_lock
is similar to the one used for unique_lock
: The template argument Mutex
has a reduced requirement set that is not
sufficient for all operations. Only those members that require stronger requirements of SharedTimedMutexType
specify that additionally in the Requires element of the corresponding prototype specifications.
SharedLockable
and SharedTimedLockable
types which could be satisfied by user-provided types as well, because the
SharedMutexType
and SharedTimedMutexType
requirements are essentially restricted to an enumerated set of
types provided by the Standard Library. But this extension seemed too large for this issue and can be easily fixed later
without any harm.
Previous resolution [SUPERSEDED]:
This wording is relative to N3936.
Change 32.6.4.2 [thread.mutex.requirements.mutex] as indicated:
-1- The mutex types are the standard library types
std::mutex
,std::recursive_mutex
,std::timed_mutex
,std::recursive_timed_mutex
, andstd::shared_timed_mutex
. They shall meet theMutexType
requirements set out in this section. In this description,m
denotes an object of a mutex type.Change 32.6.4.2.2 [thread.mutex.class] as indicated:
-3- The class
mutex
shall satisfy all theMutexType
requirements (32.6.4.2 [thread.mutex.requirements.mutex]32.6.4 [thread.mutex.requirements]). It shall be a standard-layout class (Clause 9).Change 32.6.4.2.3 [thread.mutex.recursive] as indicated:
-2- The class
recursive_mutex
shall satisfy all theMutexMutexType
requirements (32.6.4.2 [thread.mutex.requirements.mutex]32.6.4 [thread.mutex.requirements]). It shall be a standard-layout class (Clause 9).Change 32.6.4.3 [thread.timedmutex.requirements] as indicated:
-1- The timed mutex types are the standard library types
std::timed_mutex
,std::recursive_timed_mutex
, andstd::shared_timed_mutex
. They shall meet theTimedMutexType
requirements set out below. In this description,m
denotes an object of a mutex type,rel_time
denotes an object of an instantiation ofduration
(20.12.5), andabs_time
denotes an object of an instantiation oftime_point
(20.12.6).Change 32.6.4.3.2 [thread.timedmutex.class] as indicated:
-2- The class
timed_mutex
shall satisfy all of theTimedMutexType
requirements (32.6.4.3 [thread.timedmutex.requirements]). It shall be a standard-layout class (Clause 9).Change 32.6.4.3.3 [thread.timedmutex.recursive] as indicated:
-2- The class
recursive_timed_mutex
shall satisfy all of theTimedMutexType
requirements (32.6.4.3 [thread.timedmutex.requirements]). It shall be a standard-layout class (Clause 9).Change 32.6.4.5 [thread.sharedtimedmutex.requirements] as indicated: [Drafting note: The reference to the timed mutex types requirements has been moved after introducing the new requirement set to ensure that
SharedTimedMutexType
refineTimedMutexType
.]-1- The standard library type
-?- The shared timed mutex types shall meet thestd::shared_timed_mutex
is a shared timed mutex type. Shared timed mutex types shall meet theSharedTimedMutexType
requirementsof timed mutex types (32.6.4.3 [thread.timedmutex.requirements]), and additionally shall meet the requirementsset out below. In this description,m
denotes an object of a mutex type,rel_type
denotes an object of an instantiation ofduration
(20.12.5), andabs_time
denotes an object of an instantiation oftime_point
(20.12.6).TimedMutexType
requirements (32.6.4.3 [thread.timedmutex.requirements]).Change 32.6.4.5.2 [thread.sharedtimedmutex.class] as indicated:
-2- The class
shared_timed_mutex
shall satisfy all of theSharedTimedMutexType
requirements (32.6.4.5 [thread.sharedtimedmutex.requirements]). It shall be a standard-layout class (Clause 9).Change 32.6.5.5 [thread.lock.shared] as indicated: [Drafting note: Once N3995 has been applied, the following reference should be changed to the new
SharedMutexType
requirements ([thread.sharedmutex.requirements]) or even better to some newSharedLockable
requirements (to be defined) — end drafting note]-1- […] The supplied
-2- [Note:Mutex
type shall meet theshared mutexSharedTimedMutexType
requirements (32.6.4.5 [thread.sharedtimedmutex.requirements]).shared_lock<Mutex>
meets theTimedLockable
requirements (30.2.5.4). — end note]
[2016-02 Jacksonville]
Marshall to review wording.
[2018-08-23 Batavia Issues processing]
Tim to redraft.
[2021-05-18 Resolved by the adoption of P2160R1 at the February 2021 plenary. Status changed: Open → Resolved.]
Proposed resolution:
This wording is relative to N4527.
Change 32.6.4.2 [thread.mutex.requirements.mutex] as indicated:
-1- The mutex types are the standard library types
-2- The mutex types shall meet thestd::mutex
,std::recursive_mutex
,std::timed_mutex
,std::recursive_timed_mutex
,std::shared_mutex
, andstd::shared_timed_mutex
. They shall meet theMutexType
requirements set out in this section. In this description,m
denotes an object of a mutex type.Lockable
requirements (32.2.5.3 [thread.req.lockable.req]).
Change 32.6.4.2.2 [thread.mutex.class] as indicated:
-3- The class
mutex
shall satisfy all theMutexType
requirements (32.6.4.2 [thread.mutex.requirements.mutex]32.6.4 [thread.mutex.requirements]). It shall be a standard-layout class (Clause 9).
Change 32.6.4.2.3 [thread.mutex.recursive] as indicated:
-2- The class
recursive_mutex
shall satisfy all theMutexMutexType
requirements (32.6.4.2 [thread.mutex.requirements.mutex]32.6.4 [thread.mutex.requirements]). It shall be a standard-layout class (Clause 9).
Change 32.6.4.3 [thread.timedmutex.requirements] as indicated:
-1- The timed mutex types are the standard library types
-2- The timed mutex types shall meet thestd::timed_mutex
,std::recursive_timed_mutex
, andstd::shared_timed_mutex
. They shall meet theTimedMutexType
requirements set out below. In this description,m
denotes an object of a mutex type,rel_time
denotes an object of an instantiation ofduration
(20.12.5), andabs_time
denotes an object of an instantiation oftime_point
(20.12.6).TimedLockable
requirements (32.2.5.4 [thread.req.lockable.timed]).
Change 32.6.4.3.2 [thread.timedmutex.class] as indicated:
-2- The class
timed_mutex
shall satisfy all of theTimedMutexType
requirements (32.6.4.3 [thread.timedmutex.requirements]). It shall be a standard-layout class (Clause 9).
Change 32.6.4.3.3 [thread.timedmutex.recursive] as indicated:
-2- The class
recursive_timed_mutex
shall satisfy all of theTimedMutexType
requirements (32.6.4.3 [thread.timedmutex.requirements]). It shall be a standard-layout class (Clause 9).
Change 32.6.4.4 [thread.sharedmutex.requirements] as indicated: [Drafting note: The reference to the
mutex types requirements has been moved after introducing the new requirement set to ensure that
SharedMutexType
refines MutexType
.]
-1- The standard library types
-?- The shared mutex types shall meet thestd::shared_mutex
andstd::shared_timed_mutex
are shared mutex types. Shared mutex types shall meet theSharedMutexType
requirementsof mutex types (32.6.4.2 [thread.mutex.requirements.mutex]), and additionally shall meet the requirementsset out below. In this description,m
denotes an object of a shared mutex type.MutexType
requirements (32.6.4.2 [thread.mutex.requirements.mutex]).
Change 32.6.4.4.2 [thread.sharedmutex.class] as indicated:
-2- The class
shared_mutex
shall satisfy all of theSharedMutexType
requirementsfor shared mutexes(32.6.4.4 [thread.sharedmutex.requirements]). It shall be a standard-layout class (Clause 9).
Change 32.6.4.5 [thread.sharedtimedmutex.requirements] as indicated: [Drafting note: The reference to the
timed mutex types requirements has been moved after introducing the new requirement set to ensure that
SharedTimedMutexType
refines TimedMutexType
and SharedMutexType
.]
-1- The standard library type
-?- The shared timed mutex types shall meet thestd::shared_timed_mutex
is a shared timed mutex type. Shared timed mutex types shall meet theSharedTimedMutexType
requirementsof timed mutex types (32.6.4.3 [thread.timedmutex.requirements]), shared mutex types (32.6.4.4 [thread.sharedmutex.requirements]), and additionally shall meet the requirementsset out below. In this description,m
denotes an object of a shared timed mutex type,rel_type
denotes an object of an instantiation ofduration
(20.12.5), andabs_time
denotes an object of an instantiation oftime_point
(20.12.6).TimedMutexType
requirements (32.6.4.3 [thread.timedmutex.requirements]) and theSharedMutexType
requirements (32.6.4.4 [thread.sharedmutex.requirements]).
Change 32.6.4.5.2 [thread.sharedtimedmutex.class] as indicated:
-2- The class
shared_timed_mutex
shall satisfy all of theSharedTimedMutexType
requirementsfor shared timed mutexes(32.6.4.5 [thread.sharedtimedmutex.requirements]). It shall be a standard-layout class (Clause 9).
Change 32.6.5.5 [thread.lock.shared] as indicated:
-1- […] The supplied
-2- [Note:Mutex
type shall meet theshared mutexSharedMutexType
requirements (32.6.4.5 [thread.sharedtimedmutex.requirements]32.6.4.4 [thread.sharedmutex.requirements]).shared_lock<Mutex>
meets theTimedLockable
requirements (30.2.5.4). — end note]
Change 32.6.5.5.2 [thread.lock.shared.cons] as indicated:
template <class Clock, class Duration> shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);-14- Requires: The supplied
-15- Effects: Constructs an object of typeMutex
type shall meet theSharedTimedMutexType
requirements (32.6.4.5 [thread.sharedtimedmutex.requirements]). The calling thread does not own the mutex for any ownership mode.shared_lock
and callsm.try_lock_shared_until(abs_time)
. […]template <class Rep, class Period> shared_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);-17- Requires: The supplied
-18- Effects: Constructs an object of typeMutex
type shall meet theSharedTimedMutexType
requirements (32.6.4.5 [thread.sharedtimedmutex.requirements]). The calling thread does not own the mutex for any ownership mode.shared_lock
and callsm.try_lock_shared_for(rel_time)
. […]
Change 32.6.5.5.3 [thread.lock.shared.locking] as indicated:
template <class Clock, class Duration> bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);-?- Requires: The supplied
-8- Effects:Mutex
type shall meet theSharedTimedMutexType
requirements (32.6.4.5 [thread.sharedtimedmutex.requirements]).pm->try_lock_shared_until(abs_time)
. […]template <class Rep, class Period> bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);-?- Requires: The supplied
-12- Effects:Mutex
type shall meet theSharedTimedMutexType
requirements (32.6.4.5 [thread.sharedtimedmutex.requirements]).pm->try_lock_shared_for(rel_time)
. […]