<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="author" content="Hana+Dus%C3%ADkov%C3%A1">
	<meta name="description" content="">
	<meta name="generator" content="hatemplate/v2">
	<title>P3771R0: constexpr mutex, locks, and condition variable</title>
	
	<link rel="preconnect" href="https://fonts.googleapis.com">
	<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
	
	
<!-- highlight.min.js -->
<script>
/*!
  Highlight.js v11.9.0 (git: b7ec4bfafc)
  (c) 2006-2024 undefined and other contributors
  License: BSD-3-Clause
 */
var hljs=function(){"use strict";function e(t){
return t instanceof Map?t.clear=t.delete=t.set=()=>{
throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=()=>{
throw Error("set is read-only")
}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach((n=>{
const i=t[n],s=typeof i;"object"!==s&&"function"!==s||Object.isFrozen(i)||e(i)
})),t}class t{constructor(e){
void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}
ignoreMatch(){this.isMatchIgnored=!0}}function n(e){
return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")
}function i(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t]
;return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const s=e=>!!e.scope
;class o{constructor(e,t){
this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){
this.buffer+=n(e)}openNode(e){if(!s(e))return;const t=((e,{prefix:t})=>{
if(e.startsWith("language:"))return e.replace("language:","language-")
;if(e.includes(".")){const n=e.split(".")
;return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")
}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}
closeNode(e){s(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){
this.buffer+=`<span class="${e}">`}}const r=(e={})=>{const t={children:[]}
;return Object.assign(t,e),t};class a{constructor(){
this.rootNode=r(),this.stack=[this.rootNode]}get top(){
return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){
this.top.children.push(e)}openNode(e){const t=r({scope:e})
;this.add(t),this.stack.push(t)}closeNode(){
if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){
for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}
walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){
return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),
t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){
"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{
a._collapse(e)})))}}class c extends a{constructor(e){super(),this.options=e}
addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){
this.closeNode()}__addSublanguage(e,t){const n=e.root
;t&&(n.scope="language:"+t),this.add(n)}toHTML(){
return new o(this,this.options).value()}finalize(){
return this.closeAllNodes(),!0}}function l(e){
return e?"string"==typeof e?e:e.source:null}function g(e){return h("(?=",e,")")}
function u(e){return h("(?:",e,")*")}function d(e){return h("(?:",e,")?")}
function h(...e){return e.map((e=>l(e))).join("")}function f(...e){const t=(e=>{
const t=e[e.length-1]
;return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}
})(e);return"("+(t.capture?"":"?:")+e.map((e=>l(e))).join("|")+")"}
function p(e){return RegExp(e.toString()+"|").exec("").length-1}
const b=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./
;function m(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n
;let i=l(e),s="";for(;i.length>0;){const e=b.exec(i);if(!e){s+=i;break}
s+=i.substring(0,e.index),
i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?s+="\\"+(Number(e[1])+t):(s+=e[0],
"("===e[0]&&n++)}return s})).map((e=>`(${e})`)).join(t)}
const E="[a-zA-Z]\\w*",x="[a-zA-Z_]\\w*",w="\\b\\d+(\\.\\d+)?",y="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",_="\\b(0b[01]+)",O={
begin:"\\\\[\\s\\S]",relevance:0},v={scope:"string",begin:"'",end:"'",
illegal:"\\n",contains:[O]},k={scope:"string",begin:'"',end:'"',illegal:"\\n",
contains:[O]},N=(e,t,n={})=>{const s=i({scope:"comment",begin:e,end:t,
contains:[]},n);s.contains.push({scope:"doctag",
begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0})
;const o=f("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/)
;return s.contains.push({begin:h(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),s
},S=N("//","$"),M=N("/\\*","\\*/"),R=N("#","$");var j=Object.freeze({
__proto__:null,APOS_STRING_MODE:v,BACKSLASH_ESCAPE:O,BINARY_NUMBER_MODE:{
scope:"number",begin:_,relevance:0},BINARY_NUMBER_RE:_,COMMENT:N,
C_BLOCK_COMMENT_MODE:M,C_LINE_COMMENT_MODE:S,C_NUMBER_MODE:{scope:"number",
begin:y,relevance:0},C_NUMBER_RE:y,END_SAME_AS_BEGIN:e=>Object.assign(e,{
"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{
t.data._beginMatch!==e[1]&&t.ignoreMatch()}}),HASH_COMMENT_MODE:R,IDENT_RE:E,
MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:{begin:"\\.\\s*"+x,relevance:0},
NUMBER_MODE:{scope:"number",begin:w,relevance:0},NUMBER_RE:w,
PHRASAL_WORDS_MODE:{
begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
},QUOTE_STRING_MODE:k,REGEXP_MODE:{scope:"regexp",begin:/\/(?=[^/\n]*\/)/,
end:/\/[gimuy]*/,contains:[O,{begin:/\[/,end:/\]/,relevance:0,contains:[O]}]},
RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",
SHEBANG:(e={})=>{const t=/^#![ ]*\//
;return e.binary&&(e.begin=h(t,/.*\b/,e.binary,/\b.*/)),i({scope:"meta",begin:t,
end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},
TITLE_MODE:{scope:"title",begin:E,relevance:0},UNDERSCORE_IDENT_RE:x,
UNDERSCORE_TITLE_MODE:{scope:"title",begin:x,relevance:0}});function A(e,t){
"."===e.input[e.index-1]&&t.ignoreMatch()}function I(e,t){
void 0!==e.className&&(e.scope=e.className,delete e.className)}function T(e,t){
t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",
e.__beforeBegin=A,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,
void 0===e.relevance&&(e.relevance=0))}function L(e,t){
Array.isArray(e.illegal)&&(e.illegal=f(...e.illegal))}function B(e,t){
if(e.match){
if(e.begin||e.end)throw Error("begin & end are not supported with match")
;e.begin=e.match,delete e.match}}function P(e,t){
void 0===e.relevance&&(e.relevance=1)}const D=(e,t)=>{if(!e.beforeMatch)return
;if(e.starts)throw Error("beforeMatch cannot be used with starts")
;const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]
})),e.keywords=n.keywords,e.begin=h(n.beforeMatch,g(n.begin)),e.starts={
relevance:0,contains:[Object.assign(n,{endsParent:!0})]
},e.relevance=0,delete n.beforeMatch
},H=["of","and","for","in","not","or","if","then","parent","list","value"],C="keyword"
;function $(e,t,n=C){const i=Object.create(null)
;return"string"==typeof e?s(n,e.split(" ")):Array.isArray(e)?s(n,e):Object.keys(e).forEach((n=>{
Object.assign(i,$(e[n],t,n))})),i;function s(e,n){
t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((t=>{const n=t.split("|")
;i[n[0]]=[e,U(n[0],n[1])]}))}}function U(e,t){
return t?Number(t):(e=>H.includes(e.toLowerCase()))(e)?0:1}const z={},W=e=>{
console.error(e)},X=(e,...t)=>{console.log("WARN: "+e,...t)},G=(e,t)=>{
z[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),z[`${e}/${t}`]=!0)
},K=Error();function F(e,t,{key:n}){let i=0;const s=e[n],o={},r={}
;for(let e=1;e<=t.length;e++)r[e+i]=s[e],o[e+i]=!0,i+=p(t[e-1])
;e[n]=r,e[n]._emit=o,e[n]._multi=!0}function Z(e){(e=>{
e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,
delete e.scope)})(e),"string"==typeof e.beginScope&&(e.beginScope={
_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope
}),(e=>{if(Array.isArray(e.begin)){
if(e.skip||e.excludeBegin||e.returnBegin)throw W("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),
K
;if("object"!=typeof e.beginScope||null===e.beginScope)throw W("beginScope must be object"),
K;F(e,e.begin,{key:"beginScope"}),e.begin=m(e.begin,{joinWith:""})}})(e),(e=>{
if(Array.isArray(e.end)){
if(e.skip||e.excludeEnd||e.returnEnd)throw W("skip, excludeEnd, returnEnd not compatible with endScope: {}"),
K
;if("object"!=typeof e.endScope||null===e.endScope)throw W("endScope must be object"),
K;F(e,e.end,{key:"endScope"}),e.end=m(e.end,{joinWith:""})}})(e)}function V(e){
function t(t,n){
return RegExp(l(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))
}class n{constructor(){
this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}
addRule(e,t){
t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),
this.matchAt+=p(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null)
;const e=this.regexes.map((e=>e[1]));this.matcherRe=t(m(e,{joinWith:"|"
}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex
;const t=this.matcherRe.exec(e);if(!t)return null
;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),i=this.matchIndexes[n]
;return t.splice(0,n),Object.assign(t,i)}}class s{constructor(){
this.rules=[],this.multiRegexes=[],
this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){
if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n
;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),
t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){
return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){
this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){
const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex
;let n=t.exec(e)
;if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{
const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}
return n&&(this.regexIndex+=n.position+1,
this.regexIndex===this.count&&this.considerAll()),n}}
if(e.compilerExtensions||(e.compilerExtensions=[]),
e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language.  See documentation.")
;return e.classNameAliases=i(e.classNameAliases||{}),function n(o,r){const a=o
;if(o.isCompiled)return a
;[I,B,Z,D].forEach((e=>e(o,r))),e.compilerExtensions.forEach((e=>e(o,r))),
o.__beforeBegin=null,[T,L,P].forEach((e=>e(o,r))),o.isCompiled=!0;let c=null
;return"object"==typeof o.keywords&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),
c=o.keywords.$pattern,
delete o.keywords.$pattern),c=c||/\w+/,o.keywords&&(o.keywords=$(o.keywords,e.case_insensitive)),
a.keywordPatternRe=t(c,!0),
r&&(o.begin||(o.begin=/\B|\b/),a.beginRe=t(a.begin),o.end||o.endsWithParent||(o.end=/\B|\b/),
o.end&&(a.endRe=t(a.end)),
a.terminatorEnd=l(a.end)||"",o.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(o.end?"|":"")+r.terminatorEnd)),
o.illegal&&(a.illegalRe=t(o.illegal)),
o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>i(e,{
variants:null},t)))),e.cachedVariants?e.cachedVariants:q(e)?i(e,{
starts:e.starts?i(e.starts):null
}):Object.isFrozen(e)?i(e):e))("self"===e?o:e)))),o.contains.forEach((e=>{n(e,a)
})),o.starts&&n(o.starts,r),a.matcher=(e=>{const t=new s
;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"
}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"
}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(a),a}(e)}function q(e){
return!!e&&(e.endsWithParent||q(e.starts))}class J extends Error{
constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}
const Y=n,Q=i,ee=Symbol("nomatch"),te=n=>{
const i=Object.create(null),s=Object.create(null),o=[];let r=!0
;const a="Could not find the language '{}', did you forget to load/include a language module?",l={
disableAutodetect:!0,name:"Plain text",contains:[]};let p={
ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,
languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",
cssSelector:"pre code",languages:null,__emitter:c};function b(e){
return p.noHighlightRe.test(e)}function m(e,t,n){let i="",s=""
;"object"==typeof t?(i=e,
n=t.ignoreIllegals,s=t.language):(G("10.7.0","highlight(lang, code, ...args) has been deprecated."),
G("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),
s=e,i=t),void 0===n&&(n=!0);const o={code:i,language:s};N("before:highlight",o)
;const r=o.result?o.result:E(o.language,o.code,n)
;return r.code=o.code,N("after:highlight",r),r}function E(e,n,s,o){
const c=Object.create(null);function l(){if(!N.keywords)return void M.addText(R)
;let e=0;N.keywordPatternRe.lastIndex=0;let t=N.keywordPatternRe.exec(R),n=""
;for(;t;){n+=R.substring(e,t.index)
;const s=_.case_insensitive?t[0].toLowerCase():t[0],o=(i=s,N.keywords[i]);if(o){
const[e,i]=o
;if(M.addText(n),n="",c[s]=(c[s]||0)+1,c[s]<=7&&(j+=i),e.startsWith("_"))n+=t[0];else{
const n=_.classNameAliases[e]||e;u(t[0],n)}}else n+=t[0]
;e=N.keywordPatternRe.lastIndex,t=N.keywordPatternRe.exec(R)}var i
;n+=R.substring(e),M.addText(n)}function g(){null!=N.subLanguage?(()=>{
if(""===R)return;let e=null;if("string"==typeof N.subLanguage){
if(!i[N.subLanguage])return void M.addText(R)
;e=E(N.subLanguage,R,!0,S[N.subLanguage]),S[N.subLanguage]=e._top
}else e=x(R,N.subLanguage.length?N.subLanguage:null)
;N.relevance>0&&(j+=e.relevance),M.__addSublanguage(e._emitter,e.language)
})():l(),R=""}function u(e,t){
""!==e&&(M.startScope(t),M.addText(e),M.endScope())}function d(e,t){let n=1
;const i=t.length-1;for(;n<=i;){if(!e._emit[n]){n++;continue}
const i=_.classNameAliases[e[n]]||e[n],s=t[n];i?u(s,i):(R=s,l(),R=""),n++}}
function h(e,t){
return e.scope&&"string"==typeof e.scope&&M.openNode(_.classNameAliases[e.scope]||e.scope),
e.beginScope&&(e.beginScope._wrap?(u(R,_.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),
R=""):e.beginScope._multi&&(d(e.beginScope,t),R="")),N=Object.create(e,{parent:{
value:N}}),N}function f(e,n,i){let s=((e,t)=>{const n=e&&e.exec(t)
;return n&&0===n.index})(e.endRe,i);if(s){if(e["on:end"]){const i=new t(e)
;e["on:end"](n,i),i.isMatchIgnored&&(s=!1)}if(s){
for(;e.endsParent&&e.parent;)e=e.parent;return e}}
if(e.endsWithParent)return f(e.parent,n,i)}function b(e){
return 0===N.matcher.regexIndex?(R+=e[0],1):(T=!0,0)}function m(e){
const t=e[0],i=n.substring(e.index),s=f(N,e,i);if(!s)return ee;const o=N
;N.endScope&&N.endScope._wrap?(g(),
u(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(g(),
d(N.endScope,e)):o.skip?R+=t:(o.returnEnd||o.excludeEnd||(R+=t),
g(),o.excludeEnd&&(R=t));do{
N.scope&&M.closeNode(),N.skip||N.subLanguage||(j+=N.relevance),N=N.parent
}while(N!==s.parent);return s.starts&&h(s.starts,e),o.returnEnd?0:t.length}
let w={};function y(i,o){const a=o&&o[0];if(R+=i,null==a)return g(),0
;if("begin"===w.type&&"end"===o.type&&w.index===o.index&&""===a){
if(R+=n.slice(o.index,o.index+1),!r){const t=Error(`0 width match regex (${e})`)
;throw t.languageName=e,t.badRule=w.rule,t}return 1}
if(w=o,"begin"===o.type)return(e=>{
const n=e[0],i=e.rule,s=new t(i),o=[i.__beforeBegin,i["on:begin"]]
;for(const t of o)if(t&&(t(e,s),s.isMatchIgnored))return b(n)
;return i.skip?R+=n:(i.excludeBegin&&(R+=n),
g(),i.returnBegin||i.excludeBegin||(R=n)),h(i,e),i.returnBegin?0:n.length})(o)
;if("illegal"===o.type&&!s){
const e=Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"<unnamed>")+'"')
;throw e.mode=N,e}if("end"===o.type){const e=m(o);if(e!==ee)return e}
if("illegal"===o.type&&""===a)return 1
;if(I>1e5&&I>3*o.index)throw Error("potential infinite loop, way more iterations than matches")
;return R+=a,a.length}const _=O(e)
;if(!_)throw W(a.replace("{}",e)),Error('Unknown language: "'+e+'"')
;const v=V(_);let k="",N=o||v;const S={},M=new p.__emitter(p);(()=>{const e=[]
;for(let t=N;t!==_;t=t.parent)t.scope&&e.unshift(t.scope)
;e.forEach((e=>M.openNode(e)))})();let R="",j=0,A=0,I=0,T=!1;try{
if(_.__emitTokens)_.__emitTokens(n,M);else{for(N.matcher.considerAll();;){
I++,T?T=!1:N.matcher.considerAll(),N.matcher.lastIndex=A
;const e=N.matcher.exec(n);if(!e)break;const t=y(n.substring(A,e.index),e)
;A=e.index+t}y(n.substring(A))}return M.finalize(),k=M.toHTML(),{language:e,
value:k,relevance:j,illegal:!1,_emitter:M,_top:N}}catch(t){
if(t.message&&t.message.includes("Illegal"))return{language:e,value:Y(n),
illegal:!0,relevance:0,_illegalBy:{message:t.message,index:A,
context:n.slice(A-100,A+100),mode:t.mode,resultSoFar:k},_emitter:M};if(r)return{
language:e,value:Y(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:N}
;throw t}}function x(e,t){t=t||p.languages||Object.keys(i);const n=(e=>{
const t={value:Y(e),illegal:!1,relevance:0,_top:l,_emitter:new p.__emitter(p)}
;return t._emitter.addText(e),t})(e),s=t.filter(O).filter(k).map((t=>E(t,e,!1)))
;s.unshift(n);const o=s.sort(((e,t)=>{
if(e.relevance!==t.relevance)return t.relevance-e.relevance
;if(e.language&&t.language){if(O(e.language).supersetOf===t.language)return 1
;if(O(t.language).supersetOf===e.language)return-1}return 0})),[r,a]=o,c=r
;return c.secondBest=a,c}function w(e){let t=null;const n=(e=>{
let t=e.className+" ";t+=e.parentNode?e.parentNode.className:""
;const n=p.languageDetectRe.exec(t);if(n){const t=O(n[1])
;return t||(X(a.replace("{}",n[1])),
X("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}
return t.split(/\s+/).find((e=>b(e)||O(e)))})(e);if(b(n))return
;if(N("before:highlightElement",{el:e,language:n
}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e)
;if(e.children.length>0&&(p.ignoreUnescapedHTML,p.throwUnescapedHTML))throw new J("One of your code blocks includes unescaped HTML.",e.innerHTML)
;t=e;const i=t.textContent,o=n?m(i,{language:n,ignoreIllegals:!0}):x(i)
;e.innerHTML=o.value,e.dataset.highlighted="yes",((e,t,n)=>{const i=t&&s[t]||n
;e.classList.add("hljs"),e.classList.add("language-"+i)
})(e,n,o.language),e.result={language:o.language,re:o.relevance,
relevance:o.relevance},o.secondBest&&(e.secondBest={
language:o.secondBest.language,relevance:o.secondBest.relevance
}),N("after:highlightElement",{el:e,result:o,text:i})}let y=!1;function _(){
"loading"!==document.readyState?document.querySelectorAll(p.cssSelector).forEach(w):y=!0
}function O(e){return e=(e||"").toLowerCase(),i[e]||i[s[e]]}
function v(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{
s[e.toLowerCase()]=t}))}function k(e){const t=O(e)
;return t&&!t.disableAutodetect}function N(e,t){const n=e;o.forEach((e=>{
e[n]&&e[n](t)}))}
"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(()=>{
y&&_()}),!1),Object.assign(n,{highlight:m,highlightAuto:x,highlightAll:_,
highlightElement:w,
highlightBlock:e=>(G("10.7.0","highlightBlock will be removed entirely in v12.0"),
G("10.7.0","Please use highlightElement now."),w(e)),configure:e=>{p=Q(p,e)},
initHighlighting:()=>{
_(),G("10.6.0","initHighlighting() deprecated.  Use highlightAll() now.")},
initHighlightingOnLoad:()=>{
_(),G("10.6.0","initHighlightingOnLoad() deprecated.  Use highlightAll() now.")
},registerLanguage:(e,t)=>{let s=null;try{s=t(n)}catch(t){
if(W("Language definition for '{}' could not be registered.".replace("{}",e)),
!r)throw t;W(t),s=l}
s.name||(s.name=e),i[e]=s,s.rawDefinition=t.bind(null,n),s.aliases&&v(s.aliases,{
languageName:e})},unregisterLanguage:e=>{delete i[e]
;for(const t of Object.keys(s))s[t]===e&&delete s[t]},
listLanguages:()=>Object.keys(i),getLanguage:O,registerAliases:v,
autoDetection:k,inherit:Q,addPlugin:e=>{(e=>{
e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{
e["before:highlightBlock"](Object.assign({block:t.el},t))
}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{
e["after:highlightBlock"](Object.assign({block:t.el},t))})})(e),o.push(e)},
removePlugin:e=>{const t=o.indexOf(e);-1!==t&&o.splice(t,1)}}),n.debugMode=()=>{
r=!1},n.safeMode=()=>{r=!0},n.versionString="11.9.0",n.regex={concat:h,
lookahead:g,either:f,optional:d,anyNumberOfTimes:u}
;for(const t in j)"object"==typeof j[t]&&e(j[t]);return Object.assign(n,j),n
},ne=te({});return ne.newInstance=()=>te({}),ne}()
;"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs);/*! `cpp` grammar compiled for Highlight.js 11.9.0 */
(()=>{var e=(()=>{"use strict";return e=>{const t=e.regex,a=e.COMMENT("//","$",{
contains:[{begin:/\\\n/}]
}),n="decltype\\(auto\\)",r="[a-zA-Z_]\\w*::",i="(?!struct)("+n+"|"+t.optional(r)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",s={
className:"type",begin:"\\b[a-z\\d_]*_t\\b"},c={className:"string",variants:[{
begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{
begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",
end:"'",illegal:"."},e.END_SAME_AS_BEGIN({
begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={
className:"number",variants:[{
begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"
},{
begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"
}],relevance:0},l={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{
keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"
},contains:[{begin:/\\\n/,relevance:0},e.inherit(c,{className:"string"}),{
className:"string",begin:/<.*?>/},a,e.C_BLOCK_COMMENT_MODE]},u={
className:"title",begin:t.optional(r)+e.IDENT_RE,relevance:0
},d=t.optional(r)+e.IDENT_RE+"\\s*\\(",p={
type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],
keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],
literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],
_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]
},_={className:"function.dispatch",relevance:0,keywords:{
_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]
},
begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))
},m=[_,l,s,a,e.C_BLOCK_COMMENT_MODE,o,c],f={variants:[{begin:/=/,end:/;/},{
begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],
keywords:p,contains:m.concat([{begin:/\(/,end:/\)/,keywords:p,
contains:m.concat(["self"]),relevance:0}]),relevance:0},g={className:"function",
begin:"("+i+"[\\*&\\s]+)+"+d,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,
keywords:p,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:n,keywords:p,relevance:0},{
begin:d,returnBegin:!0,contains:[u],relevance:0},{begin:/::/,relevance:0},{
begin:/:/,endsWithParent:!0,contains:[c,o]},{relevance:0,match:/,/},{
className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,
contains:[a,e.C_BLOCK_COMMENT_MODE,c,o,s,{begin:/\(/,end:/\)/,keywords:p,
relevance:0,contains:["self",a,e.C_BLOCK_COMMENT_MODE,c,o,s]}]
},s,a,e.C_BLOCK_COMMENT_MODE,l]};return{name:"C++",
aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:p,illegal:"</",
classNameAliases:{"function.dispatch":"built_in"},
contains:[].concat(f,g,_,m,[l,{
begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function)\\s*<(?!<)",
end:">",keywords:p,contains:["self",s]},{begin:e.IDENT_RE+"::",keywords:p},{
match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],
className:{1:"keyword",3:"title.class"}}])}}})();hljs.registerLanguage("cpp",e)
})();
</script>

<!-- merge-html.js -->
<script>
var mergeHTMLPlugin = (function () {
  'use strict';

  var originalStream;

  /**
   * @param {string} value
   * @returns {string}
   */
  function escapeHTML(value) {
    return value
      .replace(/&/g, '&amp;')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;')
      .replace(/"/g, '&quot;')
      .replace(/'/g, '&#x27;');
  }

  /* plugin itself */

  /** @type {HLJSPlugin} */
  const mergeHTMLPlugin = {
    // preserve the original HTML token stream
    "before:highlightElement": ({ el }) => {
      originalStream = nodeStream(el);
    },
    // merge it afterwards with the highlighted token stream
    "after:highlightElement": ({ el, result, text }) => {
      if (!originalStream.length) return;

      const resultNode = document.createElement('div');
      resultNode.innerHTML = result.value;
      result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
      el.innerHTML = result.value;
    }
  };

  /* Stream merging support functions */

  /**
   * @typedef Event
   * @property {'start'|'stop'} event
   * @property {number} offset
   * @property {Node} node
   */

  /**
   * @param {Node} node
   */
  function tag(node) {
    return node.nodeName.toLowerCase();
  }

  /**
   * @param {Node} node
   */
  function nodeStream(node) {
    /** @type Event[] */
    const result = [];
    (function _nodeStream(node, offset) {
      for (let child = node.firstChild; child; child = child.nextSibling) {
        if (child.nodeType === 3) {
          offset += child.nodeValue.length;
        } else if (child.nodeType === 1) {
          result.push({
            event: 'start',
            offset: offset,
            node: child
          });
          offset = _nodeStream(child, offset);
          // Prevent void elements from having an end tag that would actually
          // double them in the output. There are more void elements in HTML
          // but we list only those realistically expected in code display.
          if (!tag(child).match(/br|hr|img|input/)) {
            result.push({
              event: 'stop',
              offset: offset,
              node: child
            });
          }
        }
      }
      return offset;
    })(node, 0);
    return result;
  }

  /**
   * @param {any} original - the original stream
   * @param {any} highlighted - stream of the highlighted source
   * @param {string} value - the original source itself
   */
  function mergeStreams(original, highlighted, value) {
    let processed = 0;
    let result = '';
    const nodeStack = [];

    function selectStream() {
      if (!original.length || !highlighted.length) {
        return original.length ? original : highlighted;
      }
      if (original[0].offset !== highlighted[0].offset) {
        return (original[0].offset < highlighted[0].offset) ? original : highlighted;
      }

      /*
      To avoid starting the stream just before it should stop the order is
      ensured that original always starts first and closes last:

      if (event1 == 'start' && event2 == 'start')
        return original;
      if (event1 == 'start' && event2 == 'stop')
        return highlighted;
      if (event1 == 'stop' && event2 == 'start')
        return original;
      if (event1 == 'stop' && event2 == 'stop')
        return highlighted;

      ... which is collapsed to:
      */
      return highlighted[0].event === 'start' ? original : highlighted;
    }

    /**
     * @param {Node} node
     */
    function open(node) {
      /** @param {Attr} attr */
      function attributeString(attr) {
        return ' ' + attr.nodeName + '="' + escapeHTML(attr.value) + '"';
      }
      // @ts-ignore
      result += '<' + tag(node) + [].map.call(node.attributes, attributeString).join('') + '>';
    }

    /**
     * @param {Node} node
     */
    function close(node) {
      result += '</' + tag(node) + '>';
    }

    /**
     * @param {Event} event
     */
    function render(event) {
      (event.event === 'start' ? open : close)(event.node);
    }

    while (original.length || highlighted.length) {
      let stream = selectStream();
      result += escapeHTML(value.substring(processed, stream[0].offset));
      processed = stream[0].offset;
      if (stream === original) {
        /*
        On any opening or closing tag of the original markup we first close
        the entire highlighted node stack, then render the original tag along
        with all the following original tags at the same offset and then
        reopen all the tags on the highlighted stack.
        */
        nodeStack.reverse().forEach(close);
        do {
          render(stream.splice(0, 1)[0]);
          stream = selectStream();
        } while (stream === original && stream.length && stream[0].offset === processed);
        nodeStack.reverse().forEach(open);
      } else {
        if (stream[0].event === 'start') {
          nodeStack.push(stream[0].node);
        } else {
          nodeStack.pop();
        }
        render(stream.splice(0, 1)[0]);
      }
    }
    return result + escapeHTML(value.substr(processed));
  }

  return mergeHTMLPlugin;

}());
</script>

<!-- trim-nicely.js -->
<script>
var trimNicely = (function () {
  'use strict';

	// this is code from reveal.js under following license:
	
	// Copyright (C) 2011-2024 Hakim El Hattab, http://hakim.se, and reveal.js contributors
  // 
	// Permission is hereby granted, free of charge, to any person obtaining a copy
	// of this software and associated documentation files (the "Software"), to deal
	// in the Software without restriction, including without limitation the rights
	// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	// copies of the Software, and to permit persons to whom the Software is
	// furnished to do so, subject to the following conditions:
  // 
	// The above copyright notice and this permission notice shall be included in
	// all copies or substantial portions of the Software.
  // 
	// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	// THE SOFTWARE.

	// Function to perform a better "data-trim" on code snippets
	// Will slice an indentation amount on each line of the snippet (amount based on the line having the lowest indentation length)
	function betterTrim(snippetEl) {
		// Helper functions
		function trimLeft(val) {
			// Adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
			return val.replace(/^[\s\uFEFF\xA0]+/g, '');
		}
		function trimLineBreaks(input) {
			//console.log(input);
			var lines = input.split("\n");

			// Trim line-breaks from the beginning
			for (var i = 0; i < lines.length; i++) {
				if (lines[i].trim() === '') {
					lines.splice(i--, 1);
				} else break;
			}

			// Trim line-breaks from the end
			for (var i = lines.length-1; i >= 0; i--) {
				if (lines[i].trim() === '') {
					lines.splice(i, 1);
				} else break;
			}

			return lines.join("\n");
		}

		// Main function for betterTrim()
		return (function(snippetEl) {
			var content = trimLineBreaks(snippetEl.innerHTML);
			var lines = content.split("\n");
			// Calculate the minimum amount to remove on each line start of the snippet (can be 0)
			var pad = lines.reduce(function(acc, line) {
				if (line.length > 0 && trimLeft(line).length > 0 && acc > line.length - trimLeft(line).length) {
					return line.length - trimLeft(line).length;
				}
				return acc;
			}, Number.POSITIVE_INFINITY);
			// Slice each line with this amount
			return lines.map(function(line, index) {
				return line.slice(pad);
			})
			.join("\n");
		})(snippetEl);
	}
	

  /** @type {HLJSPlugin} */
  const trimNicely = {
    // preserve the original HTML token stream
    "before:highlightElement": ({ el }) => {
			if (!el.hasAttribute("no-data-trim")) {
				el.innerHTML = betterTrim(el);
			}
			
    },
    // merge it afterwards with the highlighted token stream
    "after:highlightElement": ({ el, result, text }) => {
      //if (!originalStream.length) return;
      //
      //const resultNode = document.createElement('div');
      //resultNode.innerHTML = result.value;
      //result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
      //el.innerHTML = result.value;
    }
  };

  /* Stream merging support functions */

  

  return trimNicely;

}());
</script>

	
<!-- Noto Serif (external font) -->
<link href="https://fonts.googleapis.com/css?family=Noto+Serif" rel="stylesheet" blocking="render"></link>
	
<!-- Noto Sans (external font) -->
<link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet" blocking="render"></link>
	
	
<!-- Fira Code (external font) -->
<link href="https://fonts.googleapis.com/css?family=Fira+Code" rel="stylesheet" blocking="render"></link>
	
<!-- eel-hana.css -->
<style>
.wording  {
    font-family: 'Noto Serif';
    hyphens: auto;
    line-height: 1.5;
    font-size: var(--base-font-size-10);
    padding-left: 3em;
}

.wording div {
    background: inherit;
}

.wording div.wrapper {
    max-width: 20cm;
    margin: auto;
}

.wording div.texpara {
    margin-top: 3pt;
    margin-bottom: 3pt;
}

.wording table div.texpara {
    margin-top: 0;
    margin-bottom: 0;
}

.wording table.enumerate div.texpara {
    margin-top: 3pt;
    margin-bottom: 3pt;
}

.wording ul {
    list-style-type: none;
    padding-left: 9mm;
    margin-top: 0;
    margin-bottom: 0;
}

.wording ol {
    margin-top: 0;
    margin-bottom: 0;
}

.wording a {
    text-decoration: none;
}

.wording a.hidden_link {
    text-decoration: none;
    color: inherit;
}

.wording li {
    margin-top: 3pt;
    margin-bottom: 3pt;
}

.wording h1 {
    line-height: 1;
    margin-top: 10pt;
    margin-bottom: 10pt;
}

.wording h2 {
    line-height: 1;
    font-size: var(--base-font-size-14);
    margin-top: 10pt;
    margin-bottom: 10pt;
}

.wording h2::after {
    content: "";
    clear: both;
    display: table;
}

.wording h3 {
    line-height: 1;
    margin-top: 10pt;
    margin-bottom: 10pt;
}

.wording h3::after {
    content: "";
    clear: both;
    display: table;
}

.wording h4 {
    line-height: 1;
    margin-top: 10pt;
    margin-bottom: 10pt;
}

.wording h4::after {
    content: "";
    clear: both;
    display: table;
}

.wording ul > li:before {
    content: "\2014";
    position: absolute;
    margin-left: -1.5em;
}

.wording .shy:before {
    content: "\00ad";
    /* This is U+00AD SOFT HYPHEN, same as &shy, but we put it in :before
    	to stop it from being included when the text is copied to the clipboard
    	with Firefox, which is especially annoying when copying to a terminal,
    	where the hyphen characters will show up. */
}


.wording .abbr_ref {
    float: right;
}

.wording .folded_abbr_ref {
    float: right;
}

.wording .unfolded_abbr_ref {
    display: none;
}

.wording .secnum {
    display: inline-block;
    min-width: 35pt;
}

.wording .annexnum {
    display: block;
}

.wording div.sourceLinkParent {
    float: right;
}

.wording a.sourceLink {
    position: absolute;
    opacity: 0;
    margin-left: 10pt;
}

.wording a.sourceLink:hover {
    opacity: 1;
}

.wording a.itemDeclLink {
    position: absolute;
    font-size: 75%;
    text-align: right;
    width: 5em;
    opacity: 0;
}

.wording a.itemDeclLink:hover {
    opacity: 1;
}

.wording div.marginalizedparent {
    position: relative;
    left: -18mm;
}

.wording a.marginalized {
    width: 15mm;
    position: absolute;
    font-size: var(--base-font-size-7);
    text-align: right;
}

.wording a.enumerated_item_num {
    display: block;
    margin-top: 3pt;
    margin-bottom: 3pt;
    margin-right: 6pt;
}

.wording div.para {
    margin-bottom: 6pt;
    margin-top: 6pt;
    text-align: justify;
    min-height: 1.2em;
}

.wording div.section {
    text-align: justify;
}

.wording div.sentence {
    display: inline;
}

.wording a.index {
    position: relative;
    float: right;
    right: -1em;
    display: none;
}

.wording a.index:before {
    position: absolute;
    content: "⟵";
    background-color: #C9FBC9;
}


.wording .indexitems {
    margin-left: 2em;
    text-indent: -2em;
}

.wording div.itemdescr {
    margin-left: 12mm;
}

.wording .bnf {
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-10);
    font-style: italic;
    margin-left: 25pt;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    text-indent: -3em;
    padding-left: 3em;
    line-height: 1.5;
}

.wording div.bnf span.texttt {
    font-family: 'Noto Sans Mono';
    font-style: normal;
}

.wording .rebnf {
    font-family: 'Noto Serif';
    font-style: italic;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    margin-left: 30pt;
    text-indent: -3em;
    padding-left: 3em;
    line-height: 1.5;
}

.wording .simplebnf {
    font-family: 'Noto Serif';
    font-style: italic;
    font-size: var(--base-font-size-10);
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    margin-left: 30pt;
    line-height: 1.5;
}

.wording span.textnormal {
    font-style: normal;
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-10);
    white-space: normal;
}

.wording .bnf span.textnormal {
    font-style: normal;
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-10);
    white-space: normal;
}

.wording p {
    margin-top: 4pt;
    margin-bottom: 4pt;
}

.wording span.rlap {
    display: inline-block;
    width: 0px;
    text-indent: 0;
}

.wording span.terminal {
    font-family: 'Noto Sans Mono';
    font-style: normal;
    font-size: var(--base-font-size-9);
    white-space: pre-wrap;
}

.wording span.noncxxterminal {
    font-family: 'Noto Sans Mono';
    font-style: normal;
    font-size: var(--base-font-size-9);
}

.wording span.term {
    font-style: italic;
}

.wording span.tcode {
    font-family: 'Noto Sans Mono';
    font-style: normal;
}

.wording span.textbf {
    font-weight: bold;
}

.wording span.textsf {
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-10);
}

.wording div.footnote span.textsf {
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-8);
}

.wording .bnf span.textsf {
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-10);
}

.wording .simplebnf span.textsf {
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-10);
}

.wording .example span.textsf {
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-10);
}

.wording span.textsc {
    font-variant: small-caps;
}

.wording span.nontermdef {
    font-style: italic;
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-10);
}

.wording .rebnf a.nontermdef {
    font-style: italic;
    font-family: 'Noto Serif';
}

.wording span.emph {
    font-style: italic;
}

.wording span.techterm {
    font-style: italic;
}

.wording span.mathit {
    font-style: italic;
}

.wording span.mathsf {
    font-family: 'Noto Sans';
}

.wording span.mathrm {
    font-family: 'Noto Serif';
    font-style: normal;
}

.wording span.textrm {
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-10);
}

.wording span.textsl {
    font-style: italic;
}

.wording span.mathtt {
    font-family: 'Noto Sans Mono';
    font-style: normal;
}

.wording span.mbox {
    font-family: 'Noto Serif';
    font-style: normal;
}

.wording span.ungap {
    display: inline-block;
    width: 2pt;
}

.wording span.texttt {
    font-family: 'Noto Sans Mono';
}

.wording span.textit {
    font-style: italic;
}

.wording div.footnote span.texttt {
    font-family: 'Noto Sans Mono';
}

.wording span.tcode_in_codeblock {
    font-family: 'Noto Sans Mono';
    font-style: normal;
    font-size: var(--base-font-size-9);
}

.wording span.phantom {
    color: white;
}
/* Unfortunately, this way the text is still selectable. Another
	option is display:none, but then we lose the nice layout.
	Todo: find proper solution. */

.wording span.math {
    font-style: normal;
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-10);
}

.wording span.mathblock {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-top: 1.2em;
    margin-bottom: 1.2em;
    text-align: center;
}

.wording span.mathalpha {
    font-style: italic;
}

.wording span.synopsis {
    font-weight: bold;
    margin-top: 0.5em;
    display: block;
}

.wording span.definition {
    font-weight: bold;
    display: block;
}

.wording .codeblock {
    font-family: 'Noto Sans Mono';
    margin-left: 1.2em;
    line-height: 1.5;
    font-size: var(--base-font-size-9);
    white-space: pre;
    display: block;
    margin-top: 3pt;
    margin-bottom: 3pt;
		overflow-x: visible;
		overflow-y: default;
}

.wording table .codeblock {
    margin-right: 0;
}

.wording .outputblock {
    margin-left: 1.2em;
    line-height: 1.5;
    font-family: 'Noto Sans Mono';
    font-size: var(--base-font-size-9);
}

.wording code {
    font-family: 'Noto Sans Mono';
    font-style: normal;
}

.wording div.itemdecl {
    margin-top: 2ex;
}

.wording code.itemdeclcode {
    white-space: pre;
    font-family: 'Noto Sans Mono';
    font-size: var(--base-font-size-9);
    display: block;
		overflow-x: visible;
		overflow-y: default;
}

.wording .comment {
    color: green;
    font-style: italic;
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-10);
}

.wording .footnote .comment {
    color: green;
    font-style: italic;
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-8);
}

.wording .example .comment {
    color: green;
    font-style: italic;
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-9);
}

.wording .note .comment {
    color: green;
    font-style: italic;
    font-family: 'Noto Serif';
    font-size: var(--base-font-size-9);
}

.wording span.keyword {
    color: #00607c;
    font-style: normal;
}

.wording span.parenthesis {
    color: #af1915;
}

.wording span.curlybracket {
    color: #af1915;
}

.wording span.squarebracket {
    color: #af1915;
}

.wording span.literal {
    color: #9F6807;
}

.wording span.literalterminal {
    color: #9F6807;
    font-family: 'Noto Sans Mono';
    font-style: normal;
}

.wording span.operator {
    color: #570057;
}

.wording span.anglebracket {
    color: #570057;
}

.wording span.preprocessordirective {
    color: #6F4E37;
}

.wording span.textsuperscript {
    vertical-align: super;
    font-size: smaller;
    line-height: 0;
}

.wording .footnoteref {
    vertical-align: super;
    font-size: smaller;
    line-height: 0;
}

.wording .footnote {
    font-size: var(--base-font-size-8);
}

.wording .footnote .math {
    font-size: var(--base-font-size-8);
}

.wording .footnotenum {
    display: inline-block;
    text-align: right;
    margin-right: 1mm;
    width: 4ch;
}

.wording .footnoteBacklink {
    display: none;
}

.wording .footnoteSeparator {
    background: black;
    margin-top: 5mm;
    height: 1px;
    width: 6cm;
}

.wording div.minipage {
    display: inline-block;
    margin-right: 3em;
}

.wording div.numberedTable {
    text-align: center;
    margin-left: 1em;
    margin-right: 1em;
    margin-bottom: 12pt;
    margin-top: 8pt;
}

.wording div.figure {
    text-align: center;
    margin-left: 2em;
    margin-right: 2em;
    margin-bottom: 12pt;
    margin-top: 3pt;
}

.wording table {
    border: 1px solid black;
    border-collapse: collapse;
    margin-left: auto;
    margin-right: auto;
    margin-top: 7pt;
    text-align: left;
}

.wording td, .wording th {
    padding-left: 8pt;
    padding-right: 8pt;
    vertical-align: top;
}

.wording td.empty {
    padding: 0px;
    padding-left: 1px;
}

.wording td.left {
    text-align: left;
}

.wording td.hidden {
    padding: 0;
    width: 0;
}

.wording td.right {
    text-align: right;
}

.wording td.center {
    text-align: center;
}

.wording td.justify {
    text-align: justify;
}

.wording td.border {
    border-left: 1px solid black;
}

.wording tr.rowsep, .wording td.cline {
    border-top: 1px solid black;
}

.wording tr.capsep {
    border-top: 3px solid black;
    border-top-style: double;
}

.wording th {
    border-bottom: 1px solid black;
}

.wording span.centry {
    font-weight: bold;
}

.wording div.table {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    width: 90%;
}

.wording span.indented {
    background: inherit;
    display: block;
    margin-left: 2em;
    margin-bottom: 1em;
    margin-top: 1em;
}

.wording span.uppercase {
    text-transform: uppercase;
}

.wording span.ucode {
    font-variant: small-caps;
    text-transform: uppercase;
    font-size: 90%;
}

.wording span.uname {
    font-variant: small-caps;
    text-transform: uppercase;
    font-size: 90%;
}

.wording table.enumerate {
    border: 0;
    margin: 0;
}

.wording table.enumerate td {
    padding: 0;
}

.wording table.enumerate td:first-child {
    width: 1cm;
    text-align: right;
}

@media (prefers-color-scheme: dark) {
    .wording {
        background-color: #171717;
        color: #d0d0d0;
    }

    .wording span.mjx-mstyle {
        color: #d0d0d0 !important
    }

    .wording a.hidden_link {
        text-decoration: none;
        color: inherit;
    }

    .wording span.phantom {
        color: #171717;
    }

    .wording a.index:before {
        color: #d0d0d0;
        background-color: #4b6353;
    }

    .wording .comment {
        color: #35da00;
    }

    .wording .footnote .comment {
        color: #35da00;
    }

    .wording .example .comment {
        color: #35da00;
    }

    .wording .note .comment {
        color: #35da00;
    }

    .wording span.keyword {
        color: #12cabe;
    }

    .wording span.parenthesis {
        color: #ff1515;
    }

    .wording span.curlybracket {
        color: #ff1515;
    }

    .wording span.squarebracket {
        color: #ff1515;
    }

    .wording span.literal {
        color: #dfa837;
    }

    .wording span.literalterminal {
        color: #dfa837;
    }

    .wording span.operator {
        color: #baa6b9;
    }

    .wording span.anglebracket {
        color: #baa6b9;
    }

    .wording span.preprocessordirective {
        color: #b27c58;
    }

    .wording table {
        border-color: #d0d0d0;
    }

    .wording td.border {
        border-color: #d0d0d0;
    }

    .wording td.border {
        border-left-color: #d0d0d0;
    }

    .wording tr.rowsep, td.cline {
        border-top-color: #d0d0d0;
    }

    .wording tr.capsep {
        border-top-color: #d0d0d0;
    }

    .wording th {
        border-bottom-color: #d0d0d0;
    }

    .wording .footnoteSeparator {
        background-color: #d0d0d0;
    }

    .wording text {
        fill: #d0d0d0;
    }

    .wording path {
        stroke: #d0d0d0;
    }

    .wording polygon {
        stroke: #d0d0d0;
        fill: #d0d0d0;
    }

    .wording ellipse {
        stroke: #d0d0d0;
    }

}

.wording .mjx-chtml {
    display: inline-block;
    line-height: 0;
    text-indent: 0;
    text-align: left;
    text-transform: none;
    font-style: normal;
    font-weight: normal;
    font-size: 100%;
    font-size-adjust: none;
    letter-spacing: normal;
    word-wrap: normal;
    word-spacing: normal;
    white-space: nowrap;
    float: none;
    direction: ltr;
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    border: 0;
    margin: 0;
    padding: 1px 0
}

.wording .MJXc-display {
    display: block;
    background: inherit;
    text-align: center;
    margin: 1em 0;
    padding: 0
}

.wording .mjx-chtml[tabindex]:focus, .wording  :focus .mjx-chtml[tabindex] {
    display: inline-table
}

.wording .mjx-full-width {
    text-align: center;
    display: table-cell !important;
    width: 10000em
}

.wording .mjx-math {
    display: inline-block;
    border-collapse: separate;
    border-spacing: 0
}

.wording .mjx-math * {
    display: inline-block;
    -webkit-box-sizing: content-box !important;
    -moz-box-sizing: content-box !important;
    box-sizing: content-box !important;
    text-align: left
}

.wording .mjx-numerator {
    display: block;
    background: inherit;
    text-align: center
}

.wording .mjx-denominator {
    display: block;
    background: inherit;
    text-align: center
}

.wording .MJXc-stacked {
    height: 0;
    position: relative
}

.wording .MJXc-stacked > * {
    position: absolute
}

.wording .MJXc-bevelled > * {
    display: inline-block
}

.wording .mjx-stack {
    display: inline-block
}

.wording .mjx-op {
    display: block;
    background: inherit
}

.wording .mjx-under {
    display: table-cell
}

.wording .mjx-over {
    display: block;
    background: inherit
}

.wording .mjx-over > * {
    padding-left: 0px !important;
    padding-right: 0px !important
}

.wording .mjx-under > * {
    padding-left: 0px !important;
    padding-right: 0px !important
}

.wording .mjx-stack > .mjx-sup {
    display: block;
    background: inherit
}

.wording .mjx-stack > .mjx-sub {
    display: block;
    background: inherit
}

.wording .mjx-prestack > .mjx-presup {
    display: block;
    background: inherit
}

.wording .mjx-prestack > .mjx-presub {
    display: block;
    background: inherit
}

.wording .mjx-delim-h > .mjx-char {
    display: inline-block
}

.wording .mjx-surd {
    vertical-align: top
}

.wording .mjx-mphantom * {
    visibility: hidden
}

.wording .mjx-merror {
    background-color: #FFFF88;
    color: #CC0000;
    border: 1px solid #CC0000;
    padding: 2px 3px;
    font-style: normal;
    font-size: 90%
}

.wording .mjx-annotation-xml {
    line-height: normal
}

.wording .mjx-menclose > svg {
    fill: none;
    stroke: currentColor
}

.wording .mjx-mtr {
    display: table-row
}

.wording .mjx-mlabeledtr {
    display: table-row
}

.wording .mjx-mtd {
    display: table-cell;
    text-align: center
}

.wording .mjx-label {
    display: table-row
}

.wording .mjx-box {
    display: inline-block
}

.wording .mjx-block {
    display: block;
    background: inherit
}

.wording .mjx-span {
    display: inline
}

.wording .mjx-char {
    display: block;
    background: inherit;
    white-space: pre
}

.wording .mjx-itable {
    display: inline-table;
    width: auto
}

.wording .mjx-row {
    display: table-row
}

.wording .mjx-cell {
    display: table-cell
}

.wording .mjx-table {
    display: table;
    width: 100%
}

.wording .mjx-line {
    display: block;
    background: inherit;
    height: 0
}

.wording .mjx-strut {
    width: 0;
    padding-top: 1em
}

.wording .mjx-vsize {
    width: 0
}

.wording .MJXc-space1 {
    margin-left: .167em
}

.wording .MJXc-space2 {
    margin-left: .222em
}

.wording .MJXc-space3 {
    margin-left: .278em
}

.wording .mjx-ex-box-test {
    position: absolute;
		overflow-x: visible;
		overflow-y: default;
    width: 1px;
    height: 60ex
}

.wording .mjx-line-box-test {
    display: table !important
}

.wording .mjx-line-box-test span {
    display: table-cell !important;
    width: 10000em !important;
    min-width: 0;
    max-width: none;
    padding: 0;
    border: 0;
    margin: 0
}

.wording .MJXc-TeX-unknown-R {
    font-family: monospace;
    font-style: normal;
    font-weight: normal
}

.wording .MJXc-TeX-unknown-I {
    font-family: monospace;
    font-style: italic;
    font-weight: normal
}

.wording .MJXc-TeX-unknown-B {
    font-family: monospace;
    font-style: normal;
    font-weight: bold
}

.wording .MJXc-TeX-unknown-BI {
    font-family: monospace;
    font-style: italic;
    font-weight: bold
}

.wording .MJXc-TeX-ams-R {
    font-family: MJXc-TeX-ams-R, MJXc-TeX-ams-Rw
}

.wording .MJXc-TeX-cal-B {
    font-family: MJXc-TeX-cal-B, MJXc-TeX-cal-Bx, MJXc-TeX-cal-Bw
}

.wording .MJXc-TeX-frak-R {
    font-family: MJXc-TeX-frak-R, MJXc-TeX-frak-Rw
}

.wording .MJXc-TeX-frak-B {
    font-family: MJXc-TeX-frak-B, MJXc-TeX-frak-Bx, MJXc-TeX-frak-Bw
}

.wording .MJXc-TeX-math-BI {
    font-family: MJXc-TeX-math-BI, MJXc-TeX-math-BIx, MJXc-TeX-math-BIw
}

.wording .MJXc-TeX-sans-R {
    font-family: 'Noto Sans';
    font-size: var(--base-font-size-10);
}

.wording .MJXc-TeX-sans-B {
    font-family: MJXc-TeX-sans-B, MJXc-TeX-sans-Bx, MJXc-TeX-sans-Bw
}

.wording .MJXc-TeX-sans-I {
    font-family: MJXc-TeX-sans-I, MJXc-TeX-sans-Ix, MJXc-TeX-sans-Iw
}

.wording .MJXc-TeX-script-R {
    font-family: MJXc-TeX-script-R, MJXc-TeX-script-Rw
}

.wording .MJXc-TeX-type-R {
    font-family: 'Noto Sans Mono';
    font-size: var(--base-font-size-10);
}

.wording .MJXc-TeX-cal-R {
    font-family: MJXc-TeX-cal-R, MJXc-TeX-cal-Rw
}

.wording .MJXc-TeX-main-B {
    font-family: MJXc-TeX-main-B, MJXc-TeX-main-Bx, MJXc-TeX-main-Bw
}

.wording .MJXc-TeX-main-I {
    font-style: italic
}

.wording .MJXc-TeX-main-R {
}

.wording .MJXc-TeX-math-I {
    font-style: italic
}

.wording .MJXc-TeX-size1-R {
    font-family: MJXc-TeX-size1-R, MJXc-TeX-size1-Rw
}

.wording .MJXc-TeX-size2-R {
    font-family: MJXc-TeX-size2-R, MJXc-TeX-size2-Rw
}

.wording .MJXc-TeX-size3-R {
    font-family: MJXc-TeX-size3-R, MJXc-TeX-size3-Rw
}

.wording .MJXc-TeX-size4-R {
    font-family: MJXc-TeX-size4-R, MJXc-TeX-size4-Rw
}

.wording .MJXc-TeX-vec-R {
    font-family: MJXc-TeX-vec-R, MJXc-TeX-vec-Rw
}

.wording .MJXc-TeX-vec-B {
    font-family: MJXc-TeX-vec-B, MJXc-TeX-vec-Bx, MJXc-TeX-vec-Bw
}

@font-face {
    font-family: MJXc-TeX-ams-R;
    src: local('MathJax_AMS'), local('MathJax_AMS-Regular')
}

@font-face {
    font-family: MJXc-TeX-ams-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_AMS-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_AMS-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_AMS-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-cal-B;
    src: local('MathJax_Caligraphic Bold'), local('MathJax_Caligraphic-Bold')
}

@font-face {
    font-family: MJXc-TeX-cal-Bx;
    src: local('MathJax_Caligraphic');
    font-weight: bold
}

@font-face {
    font-family: MJXc-TeX-cal-Bw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Caligraphic-Bold.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Caligraphic-Bold.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-frak-R;
    src: local('MathJax_Fraktur'), local('MathJax_Fraktur-Regular')
}

@font-face {
    font-family: MJXc-TeX-frak-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Fraktur-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Fraktur-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-frak-B;
    src: local('MathJax_Fraktur Bold'), local('MathJax_Fraktur-Bold')
}

@font-face {
    font-family: MJXc-TeX-frak-Bx;
    src: local('MathJax_Fraktur');
    font-weight: bold
}

@font-face {
    font-family: MJXc-TeX-frak-Bw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Fraktur-Bold.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Fraktur-Bold.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-math-BI;
    src: local('MathJax_Math BoldItalic'), local('MathJax_Math-BoldItalic')
}

@font-face {
    font-family: MJXc-TeX-math-BIx;
    src: local('MathJax_Math');
    font-weight: bold;
    font-style: italic
}

@font-face {
    font-family: MJXc-TeX-math-BIw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Math-BoldItalic.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Math-BoldItalic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Math-BoldItalic.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-sans-R;
    src: local('MathJax_SansSerif'), local('MathJax_SansSerif-Regular')
}

@font-face {
    font-family: MJXc-TeX-sans-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-sans-B;
    src: local('MathJax_SansSerif Bold'), local('MathJax_SansSerif-Bold')
}

@font-face {
    font-family: MJXc-TeX-sans-Bx;
    src: local('MathJax_SansSerif');
    font-weight: bold
}

@font-face {
    font-family: MJXc-TeX-sans-Bw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Bold.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Bold.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-sans-I;
    src: local('MathJax_SansSerif Italic'), local('MathJax_SansSerif-Italic')
}

@font-face {
    font-family: MJXc-TeX-sans-Ix;
    src: local('MathJax_SansSerif');
    font-style: italic
}

@font-face {
    font-family: MJXc-TeX-sans-Iw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Italic.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Italic.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-script-R;
    src: local('MathJax_Script'), local('MathJax_Script-Regular')
}

@font-face {
    font-family: MJXc-TeX-script-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Script-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Script-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Script-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-type-R;
    src: local('MathJax_Typewriter'), local('MathJax_Typewriter-Regular')
}

@font-face {
    font-family: MJXc-TeX-type-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Typewriter-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Typewriter-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Typewriter-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-cal-R;
    src: local('MathJax_Caligraphic'), local('MathJax_Caligraphic-Regular')
}

@font-face {
    font-family: MJXc-TeX-cal-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Caligraphic-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Caligraphic-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-main-B;
    src: local('MathJax_Main Bold'), local('MathJax_Main-Bold')
}

@font-face {
    font-family: MJXc-TeX-main-Bx;
    src: local('MathJax_Main');
    font-weight: bold
}

@font-face {
    font-family: MJXc-TeX-main-Bw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Bold.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Bold.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-main-I;
    src: local('MathJax_Main Italic'), local('MathJax_Main-Italic')
}

@font-face {
    font-family: MJXc-TeX-main-Ix;
    src: local('MathJax_Main');
    font-style: italic
}

@font-face {
    font-family: MJXc-TeX-main-Iw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Italic.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Italic.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-main-R;
    src: local('MathJax_Main'), local('MathJax_Main-Regular')
}

@font-face {
    font-family: MJXc-TeX-main-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-math-I;
    src: local('MathJax_Math Italic'), local('MathJax_Math-Italic')
}

@font-face {
    font-family: MJXc-TeX-math-Ix;
    src: local('MathJax_Math');
    font-style: italic
}

@font-face {
    font-family: MJXc-TeX-math-Iw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Math-Italic.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Math-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Math-Italic.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-size1-R;
    src: local('MathJax_Size1'), local('MathJax_Size1-Regular')
}

@font-face {
    font-family: MJXc-TeX-size1-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Size1-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Size1-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size1-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-size2-R;
    src: local('MathJax_Size2'), local('MathJax_Size2-Regular')
}

@font-face {
    font-family: MJXc-TeX-size2-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Size2-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Size2-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size2-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-size3-R;
    src: local('MathJax_Size3'), local('MathJax_Size3-Regular')
}

@font-face {
    font-family: MJXc-TeX-size3-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Size3-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Size3-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size3-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-size4-R;
    src: local('MathJax_Size4'), local('MathJax_Size4-Regular')
}

@font-face {
    font-family: MJXc-TeX-size4-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Size4-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Size4-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size4-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-vec-R;
    src: local('MathJax_Vector'), local('MathJax_Vector-Regular')
}

@font-face {
    font-family: MJXc-TeX-vec-Rw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Vector-Regular.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Vector-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Vector-Regular.otf') format('opentype')
}

@font-face {
    font-family: MJXc-TeX-vec-B;
    src: local('MathJax_Vector Bold'), local('MathJax_Vector-Bold')
}

@font-face {
    font-family: MJXc-TeX-vec-Bx;
    src: local('MathJax_Vector');
    font-weight: bold
}

@font-face {
    font-family: MJXc-TeX-vec-Bw;
    src /*1*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/eot/MathJax_Vector-Bold.eot');
    src /*2*/: url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/MathJax_Vector-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Vector-Bold.otf') format('opentype')
}

.wording div.example {
	display: block;
	margin-top: 5pt;
	margin-bottom: 5pt;
	font-size: var(--base-font-size-11);
}

.wording div.note {
	display: block;
	margin-top: 5pt;
	margin-bottom: 5pt;
	font-size: var(--base-font-size-11);
}

.wording div.example {
	display: block;
	margin-top: 5pt;
	margin-bottom: 5pt;
	font-size: var(--base-font-size-9);
}

.wording div.note {
	display: block;
	margin-top: 5pt;
	margin-bottom: 5pt;
	font-size: var(--base-font-size-9);
}

.wording div.note .texttt { font-size: var(--base-font-size-9); }
.wording div.example .texttt { font-size: var(--base-font-size-9); }

.wording div.note .textsf { font-family: 'Noto Sans'; font-size: var(--base-font-size-9); }
.wording div.example .textsf { font-family: 'Noto Sans'; font-size: var(--base-font-size-9); }

.wording div.note .math { font-size: var(--base-font-size-9); }
.wording div.example .math { font-size: var(--base-font-size-9); }

.wording a.footnotenum { display: none; }
.wording div.footnote { display: none; }
.wording div.footnoteSeparator { display: none; }
.wording .footnoteref { display: none; }

.wording div.nonNormativeOnly { display: none; }


</style>
	
<!-- may.css -->
<style>
:root {
	--hana-nav-size: 300px;
	--hana-article-left-padding: 300px;
	--hana-background: white;
	--hana-foreground: black;
	--hana-accent: hsl(215, 100%, 35%);
	--hana-hsl-saturated-bright: hsl(0 100% 75%);
	--hana-hsl-saturated-bright-contrast: hsl(0 100% 0%);
	--hana-nav-hide-transform: translate(-300px, 0px);
	--hana-selected-color: hsl(from var(--hana-hsl-saturated-bright) 220 s l);
	--hana-selected-background: color-mix(in hsl, var(--hana-selected-color), var(--hana-background) 70%);
}

@media (prefers-color-scheme: dark) {
	:root {
		--hana-background: #111;
		--hana-foreground: #DDD;
		--hana-accent: hsl(215, 50%, 73%);
		--hana-hsl-saturated-bright: hsl(0 25% 25%);
		--hana-hsl-saturated-bright-contrast: hsl(0 100% 50%);
	}
}

@media print {
	:root {
		--hana-accent: hsl(215, 100%, 23%);
	}
}

@media screen and (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

@media only screen and (width >= 1000px) {
body:has(#hide.enabled) {
	--hana-article-left-padding: 0;
}
:root {
	--hana-paper-title-visibility: none;
	
		&:has(body #hide.enabled) {
			--hana-paper-title-visibility: initial;
		}
	}
}
}


@media only screen and (width < 1000px) {
	body {
		font-size: 150%;
	}
}

/* derived and named colors */
:root {
	--hana-menu-background: color-mix(in hsl, var(--hana-background), var(--hana-foreground) 3%);
	--hana-title-background: var(--hana-background);
	--hana-accent-foreground: color-mix(in lab, var(--hana-accent), var(--hana-foreground) 50%);
}

:root {
  overscroll-behavior: none;
}

body {
	overscroll-behavior: none;
	background-color: var(--hana-background);
	color: var(--hana-foreground);
	padding: 0;
	margin: 0;
	font-family: "Noto Serif", "CMU Sans Serif", "Times New Roman";
}

body::backdrop {
	background-color: var(--hana-background);
}

code {
	font-family: "Fira Code", "CMU Typewriter Text", "Times New Roman";
	font-size: 90%;
}

#hide {
	position: fixed;
	left: calc(var(--hana-nav-size) - 2em);
	bottom: 0.5em;
	cursor: pointer;
	z-index: 2000;
	transition: left 0.5s, color 0.5s, transform 0.5s ease-in-out;
	color: color-mix(in hsl, var(--hana-foreground), var(--hana-background) 80%);
	font-size: 20px;
}




@media only screen and (width >= 1000px) {
	#hide.enabled {
		left: 1em;
		transform: rotate(-180deg);
	}
	
	body {
		&:has(#hide.enabled) nav {
			transform: var(--hana-nav-hide-transform);
		}
	}
}



#paper-id {
	display: var(--hana-paper-title-visibility);
	font-size: 80%;
}

nav {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: var(--hana-nav-size);
	padding: 1em;
	background: var(--hana-menu-background);
	color: var(--hana-foreground);
	box-sizing: border-box;
	
	overflow-wrap: break-word;
	hyphens: auto;
	word-spacing: 0;
	font-size: 90%;
	overflow-y: scroll;
	
	h1 {
		margin-top: 0;
		margin-bottom: 0;
	}
	
	.side {
		font-size: 80%;
	}
	
	.paper-info {
		display: grid;
		grid-template-columns: auto 1fr;
		.key {
			text-align: right;
			font-weight: bold;
			padding-right: 0.5em;
		}
		padding-right: 1em;
	}
	
	#toc {
		display: grid;
		grid-template-columns: 1fr;
		padding-top: 0.5lh;
		padding-bottom: 1lh;
		h1 {
			margin-bottom: 0.5em;
		}
		ul {
			padding-left: 1em;
			list-style-type: square;
		}
		> ul {
			padding-left: 2em;
			margin: 0;
		}
		
	}
}

@media only screen and (width < 1000px) {
	:root {
		--hana-article-left-padding: 0;
		--hana-title-background: var(--hana-menu-background);
	}
	nav {
		position: static;
		width: 100vw;
		margin: 0;
	}
	#hide {
		display: none;
	}
}

@media print {
	:root {
		--hana-article-left-padding: 0;
		--hana-title-background: var(--hana-menu-background);
	}
	nav {
		position: static;
		width: 100vw;
		margin: 0;
		transform: none !important;
	}
	section > p, section > pre {
		break-inside: avoid;
	}
	#toc {
		display: none;
	}
	#hide {
		display: none;
	}
}


article {	
	color: var(--hana-foreground);
	padding: 1em;
	margin-left: var(--hana-article-left-padding);
	max-width: 100vw;
	
	p:has(+section) {
		margin-bottom: 0;
	}
	
	section {
		> *:last-child {
			margin-bottom: 0;
		}
	}
	
	.wording, pre, code {
		background: color-mix(in lab, var(--hana-accent), var(--hana-background) 98%);
		&code {
			color: var(--hana-accent-foreground);
		}
	}
	
	.wording, pre {
		padding: 1em;
		border-radius: 1em;
		> *:first-child {
			margin-top: 0
		}
		> *:last-child {
			margin-bottom: 0
		}
	}
	
	.wording pre {
		padding: 0;
	}
	
	&.transitionable {
		/*transition: margin-left 0.5s;*/
	}
	
	pre {
		tab-size: 2;
		
		text-align: left;
		white-space: pre-wrap;
	  word-break: break-all;
		overflow-x: wrap;
		overflow-wrap: anywhere;
		
		code.hljs {
			.added, .removed, .before, .after {
				line-height: 1.3;
			}
			
			font-variant-ligatures: none;
			line-height: 1.3;
			* {
				font-size-adjust: 0.5;
			}
			.hljs-keyword, .hljs-built_in, .hljs-type {
				font-weight: bold;
			}
			.hljs-string {
				font-style: italic;
				text-decoration: underline;
			}
			.hljs-comment {
				color: color-mix(in hsl, currentcolor, var(--hana-background) 50%);
			}
		}
	}
	
	p:first-child {
		margin-top: 0;
	}
	
	p {
		color: color-mix(in hsl, var(--hana-foreground), var(--hana-background) 15%);
		text-align: left;
		overflow-wrap: break-word;
		hyphens: auto;
		word-spacing: 0;
		text-wrap: pretty;
	}
	
	.before {
		--hana-context-background: hsl(from var(--hana-hsl-saturated-bright) 0 s l);
		--hana-context-accent: hsl(from var(--hana-hsl-saturated-bright-contrast) 0 s l);
		z-index: 10;
		padding: 0 0.5em;
	}
	.after {
		--hana-context-background: hsl(from var(--hana-hsl-saturated-bright) 90 s l);
		--hana-context-accent: hsl(from var(--hana-hsl-saturated-bright-contrast) 90 s l);
		z-index: 20;
		padding: 0 0.5em;
	}
	.removed, .rem {
		--hana-context-background: hsl(from var(--hana-hsl-saturated-bright) 0 s l);
		--hana-context-accent: hsl(from var(--hana-hsl-saturated-bright-contrast) 0 s l);
		--hana-context-decoration: hsl(from var(--hana-hsl-saturated-bright) 0 s 40);
		--hana-context-text-decoration: hsl(from var(--hana-hsl-saturated-bright) 0 s 40 / 0.75);
		text-decoration: line-through;
	}
	.added, .add, .change {
		--hana-context-background: hsl(from var(--hana-hsl-saturated-bright) 90 s l);
		--hana-context-accent: hsl(from var(--hana-hsl-saturated-bright-contrast) 90 s l);
		--hana-context-decoration: hsl(from var(--hana-hsl-saturated-bright) 90 s 40);
		--hana-context-text-decoration: hsl(from var(--hana-hsl-saturated-bright) 90 s 40 / 0.75);
		&.alt {
			--hana-context-background: hsl(from var(--hana-hsl-saturated-bright) 50 s l);
			--hana-context-accent: hsl(from var(--hana-hsl-saturated-bright-contrast) 50 s l);
			--hana-context-decoration: hsl(from var(--hana-hsl-saturated-bright) 50 s 40);
			--hana-context-text-decoration: hsl(from var(--hana-hsl-saturated-bright) 50 s 40 / 0.75);
		}
	}
	.removed, .rem, .added, .add {
		&, * {
			text-decoration-thickness: 3px;
			text-decoration-color: var(--hana-context-text-decoration);
		}
	}
	.removed, .rem, .added, .add, .change {
		border-radius: 0.5em;
	}
	.before, .after, .removed, .rem, .added, .add {
		print-color-adjust:exact;
		border: none;
		margin: 0;
		padding: 1px 0;
		background: var(--hana-context-background);
		h1, h2, h3, h4, h5, .note, .example, pre, code {
			background: inherit;
		}
		&, * {
			color: var(--hana-context-accent) !important;
		}
	}
}

body:fullscreen {
	overflow-y: scroll;
}

body:fullscreen article {
	overflow-y: scroll;
}

.added, .removed, .change {
	print-color-adjust:exact;
	&:has(&.selected-current) {
		z-index: 5006;
		position: relative;
		outline: 2px solid var(--hana-context-decoration);

		&, .added, .removed, change {
			&:not(.selected-current) {
				--hana-local-background: hsl(from var(--hana-context-background) calc(h - 15) calc(s) l);
				background: var(--hana-local-background) !important;
				outline: 1px solid var(--hana-local-background);
			}
		}
	}
}

.selected-current, .wording .texpara:has(.selected-current), .context:has(.selected-current) {
	z-index: 5005;
	position: relative;
	outline: 2px solid var(--hana-context-decoration);
	background: var(--hana-context-background);
	--special-hana: hana;
}

section:has(.selected-current) {
	& > h1 {
		z-index: 5030;
	}
	& > h2 {
		z-index: 5025;
	}
	& > h3 {
		z-index: 5020;
	}
	& > h4 {
		z-index: 5015;
	}
	& > h5 {
		z-index: 5010;
	}
}

#overlay {
	display: block;
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 5000;
	background-color: rgb(from var(--hana-background) r g b / 0.75);
	pointer-events: none;
}

/* links are all defined here! */
a {
	color: var(--hana-accent);
	&:visited {
		color: hsl(from var(--hana-accent) calc(h - 120) s l);
	}
	&:hover {
		color: hsl(from var(--hana-accent) calc(h + 120) s l) !important;
	}
	&::after {
		margin-left: 0.2em;
		display: inline-block;
		font-size: 80%;
		width: 1em;
		height: 1em;
	}
	&:target {
		outline: none;
		&::after {
			content: "⚓︎";
		}
	}
	&[href^="https://"], &[href^="http://"] {
		&:not(&.revision):not([href^="http://eel.is"]):not([href^="https://eel.is"]):not([href^="http://github.com/Eelis/"]) {
			@media only screen {
				&::after {
					font-family: "Noto Serif", "CMU Sans Serif", "Times New Roman";
					font-size: 14px;
					content: "⎋";
					transform: scale(-1, 1);
				}
			}
		}
	}
}

section {
	position: relative;
}

h1, h2, h3, h4, h5, hr {
	word-break: keep-all;
	white-space: nowrap;
	--hana-header-color: color-mix(in hsl, var(--hana-foreground), var(--hana-background) 15%);
	--hana-header-decoration-color: color-mix(in hsl, var(--hana-foreground), var(--hana-background) 75%);
	text-decoration: none;
	margin-bottom: 0;
	margin-top: 0;
	&:not(hr) {
		padding-top: 1lh;
	}
	line-height: 1.1;
	a {
		text-decoration: none;
		&, &:visited, &:hover, &:target {
			color: var(--hana-header-color) !important;
		}
	}
}

div:has(>h2) + p {
	margin-top: 0.5em;
}

hr {
	margin-top: 0.8em;
	height: 2px;
  background-color: none;
  border:none;
	border-top: 2px dotted var(--hana-header-decoration-color);
}

article {
	padding-top: 0;
}

h1#name-of-paper {
	/*position: sticky;*/
	top: 0lh;
	left: 16px;
	margin-top: 0;
	z-index: 5950;
	padding-top: 0.5lh;
	padding-bottom: 0.25lh;
}

body {
	position: relative;
}

article {
	position: relative;
	overflow-x: clip;
	/* text-wrap: pretty; // this will crash chrome */
	h1, h2, h3, h4, h5 {
		background-color: var(--hana-background);
		/*position: sticky;*/
		top: 0.5lh;
		z-index: 2000;
		box-shadow: 0 10px 10px var(--hana-background);
	}
	.wording {
		h1, h2, h3, h4, h5 {
			--hana-background: transparent;
			background-color: none;
			position: static;
			box-shadow: none;
		}
		.para:has(.marginalizedparent) {
			margin-left: 2em;
			.marginalizedparent {
				top: 1mm;
				* {
					font-size: 50%;
					color: orange;
				}
			}
		}
		code.itemdeclcode {
			overflow-wrap: anywhere !important;
			word-break: break-word;
			hyphens: auto;
			white-space: pre-wrap;
		}
	}
	h2 {
		top: 1lh;
		z-index: 1900;
		padding-left: 3px;
	}
	h3 {
		top: 2.25lh;
		z-index: 1800;
		padding-left: 6px;
	}
	h4 {
		top: 3.5lh;
		z-index: 1700;
		padding-left: 9px;
	}
	h5 {
		top: 6.5lh;
		z-index: 1800;
		padding-left: 12px;
	}
}

.wording {
	h1, h2, h3, h4, h5 {
		position: static;
	}
}

@media only screen and (width < 1000px) {
	.wording {
		padding-left: 0em !important;
		padding-right: 0em !important;
	}
	body {
		overflow-x: hidden;
	}
	article {
		padding: 0 0.5em;
	}
	p {
		padding: 0 0.5em;
	}
	h1,h2,h3,h4,h5 {
		position: static !important;
		overflow-wrap: anywhere !important;
		word-break: break-word;
		hyphens: auto;
		white-space: pre-wrap;
	}
}


article section > h1, article > h1 {
	border-bottom: 2px solid var(--hana-header-decoration-color);
}

article section > h2 {
	border-bottom: 2px solid var(--hana-header-decoration-color);
}

article section > h3 {
	border-bottom: 2px dotted var(--hana-header-decoration-color);
}

article section > h4, article section > h5 {
	border-bottom: none;
}

.wording {
	padding-left: 2em;
	
	span.codeblock  {
		text-align: left;
		white-space: pre-wrap;
	  word-break: break-all;
		overflow-x: wrap !important;
		overflow-wrap: anywhere;
	}
	
	.comment {
		color: color-mix(in hsl, var(--hana-background), var(--hana-foreground) 75%) !important;
	}
	
	.note, .example {
		background-color: rgba(from var(--hana-foreground) r g b / 3%);
		padding: 0 0.3em;
		margin: 0.3em;
		border-radius: 0.3em;
		font-size: 95% !important;
		*:not(.note):not(.example) {
			background: none;
		}
	}
	
	code {
		text-align: left;
		white-space: pre-wrap;
	  word-break: break-all;
		overflow-x: wrap;
		overflow-wrap: anywhere;
		
		em {
			& * {
				font-style: italic;
				font-weight: normal !important;
			}
		}
	}
}

code, .wording .codeblock, .wording span.texttt, .wording span.terminal, .wording span.noncxxterminal .wording span.tcode, .wording span.mathtt, .wording div.footnote span.texttt, .wording span.tcode_in_codeblock, .wording .outputblock, .wording code.itemdeclcode, .wording span.literalterminal, .wording .MJXc-TeX-type-R {
	font-family: "Fira Code", "Noto Sans Mono", monospace !important;
	font-variant-ligatures: no-contextual;
	line-height: 1.3;
	* {
		font-size-adjust: 0.5;
	}
}

.hana_wording  {
	pre {
		padding-top: 1lh !important;
	}
	h2 {
    line-height: 1 !important;
    font-size: var(--base-font-size-16) !important;
    margin-top: 10pt !important;
    margin-bottom: 10pt !important;
	}
	h3 {
    line-height: 1 !important;
    margin-top: 10pt !important;
    margin-bottom: 10pt !important;
	}
}

@media screen {
	#draft-warning {
		position: fixed;
		bottom: 0;
		right: 0;
		background: red;
		font-family: "Fira Code", "Noto Sans Mono", monospace !important;
		font-size: 150%;
		padding: 8px 100px;
		text-transform: uppercase;
		transform: translateY(-30px) translateX(80px) rotate(-45deg);
		z-index: 50000;
		color: white;
	}
}
@media print {
	#draft-warning {
		display: none;
	}
}

ul {
	&:has(label) {
		padding-left: 0;
	}
	li:has(label) {
		list-style: none;
		list-style-position: inside;
	}
}

label:has(input[type="radio"]) {
	cursor: pointer;

	padding-left: 0.5em;
	
	line-height: 1.5;
	code {
		font-size-adjust: 0.5;
	}
	
	
	
	span {
		transition: background-color 0.2s ease-out;
		padding-left: 0.5em;
		padding-right: 0.5em;
		border-radius: 0.5em;
	}
	
	&:has(input:checked) {
		text-decoration: underline;
		text-decoration-style: dotted;
		text-decoration-thickness: 2px;
		span {
			background: var(--hana-background);
		}
		/*font-weight: bold;*/
	}
	
	&:has(input:disabled:not(:checked)) {
		color: color-mix(in hsl, var(--hana-foreground), var(--hana-background) 60%);
	}
	
	input {
		vertical-align: middle;
		-webkit-appearance: none;
		appearance: none;
		background-color: transparent;
		margin: 0;
		
		box-sizing: border-box;
		width: 1lh;
		height: 1lh;
	  padding: 0;
		margin-right: 0.5em;
		transition: border 0.2s ease-out, background 0.2s ease-out;
	  border: 2px solid color-mix(in hsl, var(--hana-foreground), var(--hana-background) 25%);
	  border-radius: 50%;
	  appearance: none;
	  background-color: transparent;
	  outline: none;
		&:checked {
			background: var(--hana-selected-color);
		}
		&:disabled {
			border: 2px solid color-mix(in hsl, var(--hana-foreground), var(--hana-background) 80%);
		}
	}
}

.poll_condition {
	&.discard {
		display: none;
	}
}

span.note {
	font-size: 80%;
	color: 2px solid color-mix(in hsl, var(--hana-foreground), var(--hana-background) 25%);
}

.wording {
	section:first-child[data-related] {
		> h1, > h2, > h3, > h4, > h5 {
			margin-top: 0;
			padding-top: 0;
		}
	}
}

.wording .example {
	& > span {
		font-style: italic;
	}
}

.wording .grammar {
	padding: 0em 1em;
	ul {
		padding-left: 4em;
		li:before {
			content: "";
		}
		li {
			list-style: none !important;
			list-style-position: inside;
		}
	}
}

div.poll {
	--poll-color: hsl(from var(--hana-hsl-saturated-bright) 45 s l);
	--poll-accent-color: hsl(from var(--poll-color) h 100% l);
	background-color: color-mix(in oklch, var(--hana-background), var(--poll-color) 25%);
	padding: 0.5em 1em;
	padding-bottom: 1em;
	margin-bottom: 0.5em !important;
	border-radius: 0.5em;
	
	code {
		background: transparent;
	}
	
	> div:not(.note) {
		> span:first-child {
			font-weight: bold;
		}
	}
	div.note {
		font-size: 75%;
	}
	
	.preferred {
		padding-left: 0.5em;
		font-size: 75%;
		display: inline-block;
		transform: translate(0, -0.05em);
	}
	
	label:has(input[type="radio"]) {
		&:has(input:checked) {
			text-decoration-color: var(--poll-accent-color);
			span {
				background: var(--poll-accent-color);
			}
		}
	}
}
</style>
</head>
<body>

<!-- navigation sidebar -->
	
<nav>
<div class="paper-info">
	<span class="key">Number:</span><span>P3771R0</span>
	<span class="key">Date:</span><span><time>2025-06-30</time></span>
	<span class="key">Audience:</span><span><a href="mailto:SG1: Concurrency (YOU-NEED-JAVASCRIPT-ENABLED) #U0cxOiBDb25jdXJyZW5jeSA8cGFyYWxsZWxAbGlzdHMuaXNvY3BwLm9yZz4/c3ViamVjdD1QMzc3MVIwOiBjb25zdGV4cHIgbXV0ZXgsIGxvY2tzLCBhbmQgY29uZGl0aW9uIHZhcmlhYmxl" onclick="return send_email(this)">SG1: Concurrency</a>, <a href="mailto:Library&nbsp;Evolution (YOU-NEED-JAVASCRIPT-ENABLED) #TGlicmFyeSZuYnNwO0V2b2x1dGlvbiA8bGliLWV4dEBsaXN0cy5pc29jcHAub3JnPj9zdWJqZWN0PVAzNzcxUjA6IGNvbnN0ZXhwciBtdXRleCwgbG9ja3MsIGFuZCBjb25kaXRpb24gdmFyaWFibGU=" onclick="return send_email(this)">Library&nbsp;Evolution</a>, and <a href="mailto:Evolution (YOU-NEED-JAVASCRIPT-ENABLED) #RXZvbHV0aW9uIDxleHRAbGlzdHMuaXNvY3BwLm9yZz4/c3ViamVjdD1QMzc3MVIwOiBjb25zdGV4cHIgbXV0ZXgsIGxvY2tzLCBhbmQgY29uZGl0aW9uIHZhcmlhYmxl" onclick="return send_email(this)">Evolution</a></span>
	<span class='key'>Target:</span><span>C++29</span>	<span class="key">Author:</span><span><a href="mailto:hana dusikova (YOU-NEED-JAVASCRIPT-ENABLED) #SGFuYStEdXMlQzMlQURrb3YlQzMlQTEgPGhhbmlja2FAaGFuaWNrYS5uZXQ+P3N1YmplY3Q9UDM3NzFSMDogY29uc3RleHByIG11dGV4LCBsb2NrcywgYW5kIGNvbmRpdGlvbiB2YXJpYWJsZQ==" onclick="return send_email(this)">Hana Dusíková</a><span>
</div>
<hr/>
<div id="toc">
<ul>
<li><a href="#motivation">Motivation</a></li>
<ul>
<li><a href="#reusability">Reusability</a></li>
<ul>
<li><a href="#example-with-std%3A%3Amutex">Example with <code>std::mutex</code></a></li>
<li><a href="#example-with-std%3A%3Ashared-mutex">Example with <code>std::shared_mutex</code></a></li>
</ul>
<li><a href="#no-deadlocks">No deadlocks</a></li>
</ul>
<li><a href="#change">Change</a></li>
<ul>
<li><a href="#quesion-about-timed-locking">Quesion about timed locking</a></li>
<li><a href="#native-handles">Native handles</a></li>
<li><a href="#utility-functions">Utility functions</a></li>
</ul>
<li><a href="#implementation">Implementation</a></li>
<ul>
<li><a href="#libc%2B%2B">libc++</a></li>
<ul>
<li><a href="#why-is-it-in-source-files">why is it in source files</a></li>
<li><a href="#shared-mutex-implementation-detail-in-libc%2B%2B"><code>shared_mutex</code> implementation detail in libc++</a></li>
</ul>
<li><a href="#research-of-libstdc%2B%2B">Research of libstdc++</a></li>
<ul>
<li><a href="#std%3A%3Amutex">std::mutex</a></li>
<li><a href="#std%3A%3Ashared-mutex">std::shared_mutex</a></li>
<li><a href="#lock-guards">lock guards</a></li>
<li><a href="#std%3A%3Acondition-variable">std::condition_variable</a></li>
</ul>
<li><a href="#ms-stl">MS STL</a></li>
</ul>
<li><a href="#wording">Wording</a></li>
<ul>
<li><a href="#modify-constant-evaluation">Modify constant evaluation</a></li>
<li><a href="#mutexes-and-locking">Mutexes and locking</a></li>
<li><a href="#timing-specifications">Timing specifications</a></li>
<li><a href="#condition-variables">Condition variables</a></li>
<li><a href="#feature-test-macro">Feature test macro</a></li>
</ul>
</ul></div><div class="side">Thanks to Michal Tichák, and Tomasz Kamiński⁩ for providing feedback, help, and encouragement.</div>
</nav>
<div id="hide">◀︎</div>
<!-- main content -->
<article spellcheck="true">
	<h1 id="name-of-paper"><span id="paper-id">P3771R0: </span>constexpr mutex, locks, and condition variable</h1>
<section data-related="motivation"><h2><a href="#motivation" id="motivation">Motivation</a></h2><p>It's really hard to conditionally avoid non-<code>constexpr</code> types in a code which is supposed to be <code>constexpr</code> compatible. This paper fixes it by making these types (and algorithms) <code>constexpr</code> compatible. There is no semantical change for updated types and algorithms.</p>
<p>This paper is a continuation of paper <a href="https://wg21.link/P3309R3">P3309R3: <code>constexpr atomic &amp; atomic_ref</code></a> and makes a lot of library code reusable in <code>constexpr</code> world.</p>

<section data-related="reusability"><h3><a href="#reusability" id="reusability">Reusability</a></h3><p>Main objective is being able to reuse same code in any environment (runtime, GPU, and now also constant evaluated). This makes C++ programs much easier to read and write and more bug-prone as someone wise once said <a href="https://youtu.be/QTLn3goa3A8?t=802"><em>"for every line there is a bug"</em></a>.</p>
<p>Also it lowers cognitive burden when users don't need to care what is and what's not <code>constexpr</code> compatible.</p>
<section data-related="example-with-std%3A%3Amutex"><h4><a href="#example-with-std%3A%3Amutex" id="example-with-std%3A%3Amutex">Example with <code>std::mutex</code></a></h4><p>Type <code>std::mutex</code> has <code>constexpr</code> default constructor since C++11, but <code>std::lock_guard</code> doesn't. You can't just wrap the <code>auto _ = std::lock_guard{mtx}</code> into <code>if consteval</code>.</p>
<pre class="lang-cpp"><code>template &lt;typename T&gt; class locked_queue {
	std::queue&lt;T&gt; impl{};
	std::mutex mtx{};
public:
	locked_queue() = default;
	
	constexpr void push(T input) {
		auto _ = std::lock_guard{mtx}; <span class="before">// BEFORE: unable to call non-constexpr constructor</span>
		                               <span class="after">// AFTER: fine</span>
		impl.push(std::move(input));
	}
	constexpr std::optional&lt;T&gt; pop() {
		auto _ = std::lock_guard{mtx}; <span class="before">// BEFORE: unable to call non-constexpr constructor</span>
		                               <span class="after">// AFTER: fine</span>
		if (impl.empty()) {
			return std::nullopt;
		}
		
		auto r = std::move(impl.front());
		impl.pop();
		return r;
	}
}

consteval foo my_algorithm() {
	auto queue = locked_queue&lt;int&gt;{};
	queue.push(1);  <span class="before">// BEFORE: unable to call non-constexpr constructor of `lock_guard`</span>
	queue.push(42); <span class="before">//                                                                 </span>
	queue.push(11); <span class="before">//                                                                 </span>
	                <span class="after">// AFTER: I can reuse my code!</span>
	return process(queue); 
}
</code></pre>
<p>One possibility to make this work without this paper would look like this:</p>
<pre class="lang-cpp"><code>template &lt;typename T&gt; class locked_queue {
	std::queue&lt;T&gt; impl{};
	std::mutex mtx{};
	
	constexpr void unsync_push(T input) {
		impl.push(std::move(input));
	}
	
	constexpr std::optional&lt;T&gt; unsync_pop() {
		if (impl.empty()) {
			return std::nullopt;
		}
		
		auto r = std::move(impl.front());
		impl.pop();
		return r;
	}
	
public:
	constexpr void push(T input) {
		if consteval {
			unsafe_push(std::move(input));
		} else {
			auto _ = std::lock_guard{mtx};
			unsafe_push(std::move(input));
		}
	}
	constexpr std::optional&lt;T&gt; pop() {
		if consteval {
			return unsafe_pop();
		} else {
			auto _ = std::lock_guard{mtx};
			return unsafe_pop();
		}
	}
}</code></pre>
<p>This pattern is terrible and it creates opportunities for more bugs, and it makes testing harder (especially when test coverage mapping is used).</p>

</section><section data-related="example-with-std%3A%3Ashared-mutex"><h4><a href="#example-with-std%3A%3Ashared-mutex" id="example-with-std%3A%3Ashared-mutex">Example with <code>std::shared_mutex</code></a></h4><pre class="lang-cpp"><code>template &lt;typename T&gt; class protected_object {
	std::optional&lt;T&gt; object{std::nullopt};
	std::shared_mutex mtx{}; <span class="before">// BEFORE: unable to use non-constexpr constructor</span>
		                       <span class="after">// AFTER: fine</span>
public:
	template &lt;typename... Args&gt; constexpr void set(Args && ... args) {
		auto _ = std::unique_lock{mtx};
		object.emplace(std::forward&lt;Args&gt;(args)...);
	}
	std::optional&lt;T;&gt; get() const {
		auto _ = std::shared_lock{mtx};
		return object;
	}
}</code></pre>
<p>Type <code>std::shared_mutex</code> doesn't have <code>constexpr</code> default constructor. There is not a simple solution how to avoid the error.</p>

</section></section><section data-related="no-deadlocks"><h3><a href="#no-deadlocks" id="no-deadlocks">No deadlocks</a></h3><p>A deadlock is undefined behaviour (missing citation). Any undefined behaviour <a href="https://eel.is/c++draft/expr.const#10.4">during constant evaluation is making program ill-formed [expr.const]</a>.</p>

</section></section><section data-related="change"><h2><a href="#change" id="change">Change</a></h2><p>In terms of specification it's just adding <code>constexpr</code> everywhere in section <a href="">thread.mutex</a> (including <a href="">thread.lock</a> and <a href="">thread.once</a>) and <a href="">thread.condition</a>. Semantic of all types and algorithms is clearly defined and is non-surprising to users.</p>
<p>One optional additional wording change is making sure no synchronization primitive can leave constant evaluation in non-default state (which will be useful also in future for <code>semaphors</code>).</p>
<section data-related="quesion-about-timed-locking"><h3><a href="#quesion-about-timed-locking" id="quesion-about-timed-locking">Quesion about timed locking</a></h3><p>Types <code>timed_mutex</code>, <code>shared_timed_mutex</code>, <code>recursive_timed_mutex</code>, and some methods on <code>unique_lock</code> and <code>shared_lock</code> have functionality which allows to give up and not take the ownership of lock after certain time or at specific timepoint. There is not observable time during constant evaluation, there are three possible options:<ul>
	<li>simply not make <code>try_lock_for</code> nor <code>try_lock_until</code> functionality <code>constexpr</code> (and forcing users to <code>if consteval</code> such code away, which is against motivation of this paper),</li>
	<li>automatically fail to take ownership if already locked (author's preferred, with <a href="#wording-change-for-timed-in-constant-evaluation">wording</a>),</li>
	<li>make only <code>try_lock_for</code> <code>constexpr</code>, and not make <code>try_lock_until</code>, and block compilation for specified duration.</li>
</ul></p>
<p>I prefer option with quick failure to take the ownership, as we know in single-threaded environment we would block for some time and fail anyway. And there is no way how to observe time during constant evaluation anyway. You can think about this as fast forward of time.</p>

</section><section data-related="native-handles"><h3><a href="#native-handles" id="native-handles">Native handles</a></h3><p>Functions returning native handles are not marked <code>constexpr</code> as these are an escape hatch to use platform specific code.</p>
</section><section data-related="utility-functions"><h3><a href="#utility-functions" id="utility-functions">Utility functions</a></h3><p>There is function <a href="#nonmember"><code>notify_all_at_thread_exit</code></a> which is marked <code>constexpr</code>, in single threaded environment is a no-op and it's trivial to implement it that way. If we won't implement it, we will force users to write <code>if consteval</code> everytime they use it, and that's not a good user experience.</p>
<p>This paper also proposes making <code>constexpr</code> free functions implementing <a href="#thread.condvarany.intwait">interruptable waits</a>, and we can do so as <code>stop_token</code> is already <code>constexpr</code> default constructible thanks to making <code>shared_ptr</code> constexpr in <a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3037r6.pdf">P3037R6</a>. Because there is no other thread which can interrupt the wait, these function will behave similarly as non-interruptable wait functions (meaning fail immediately to obtain lock due <a href="#wording-change-for-timed-in-constant-evaluation">the new paragraph in [thread.req.timing]</a>).</p>
</section></section><section data-related="implementation"><h2><a href="#implementation" id="implementation">Implementation</a></h2><p>I started working on the implementation in libc++, following subsections contains notes from my research how all three major standard library implements impacted types from this paper.</p>
<section data-related="libc%2B%2B"><h3><a href="#libc%2B%2B" id="libc%2B%2B">libc++</a></h3><p>Type <code>mutex</code> and other mutex-based types has definition of methods in <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/src/mutex.cpp#L29-L142">a source file</a> in which these methods are abstract into low-level <code>__libcpp_mutex_*</code> functions, which are defined in their platform specific header files (<a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/include/__thread/support.h#L109-L119">dispatched here</a>, <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/include/__thread/support/c11.h#L38-L77">C11</a>, <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/include/__thread/support/pthread.h#L52-L106">POSIX</a>, <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/include/__thread/support/windows.h#L39-L58">win32</a> with its <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/src/support/win32/thread_win32.cpp#L42-L97">implementation</a>). Support to <code>constexpr</code> mutex default constructor is done thru providing constant <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/include/__mutex/mutex.h#L25"><code>_LIBCPP_MUTEX_INITIALIZER</code></a> which is defined as <code>{}</code> (for C11) or <code>PTHREAD_MUTEX_INITIALIZER</code> (for POSIX threads). This tells me same thing (creating <code>_LIBCPP_*_INITIALIZER</code> macros) can be done for other mutex types, as this is already supported by posix threads and can be done <a href="#ms-stl">also with win32</a>.</p>
<p>Type <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/include/__condition_variable/condition_variable.h#L89C33-L185"><code>condition_variable</code></a> default constructor is <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/include/__condition_variable/condition_variable.h#L93">surprisingly already constexpr</a> (so much about <a href="https://eel.is/c++draft/constexpr.functions#1.sentence-2">the requirement in [constexpr.function]</a>). Main functionality is in <a href="https://github.com/llvm/llvm-project/blob/749c7c5dc49a39275da6d7fc520fde2518bb2697/libcxx/src/condition_variable.cpp#L29-L39">a source file</a> where it is using already abstracted away functions similarly as mutex. These few files will need to be moved to header file too.</p>
<section data-related="why-is-it-in-source-files"><h4><a href="#why-is-it-in-source-files" id="why-is-it-in-source-files">why is it in source files</a></h4><p>Based on my experience implementing <code>constexpr</code> exceptions I have noticed libc++ tends to hide the exception throwing code in to source files in shared library. This code mostly will be needed to moved to header files anyway due the <code>constexpr</code> exception support. The two layer of abstraction for <code>mutex</code> and <code>condition_variable</code> won't be needed anymore after that.</p>
</section><section data-related="shared-mutex-implementation-detail-in-libc%2B%2B"><h4><a href="#shared-mutex-implementation-detail-in-libc%2B%2B" id="shared-mutex-implementation-detail-in-libc%2B%2B"><code>shared_mutex</code> implementation detail in libc++</a></h4><p>This is code from libc++ with removed annotational macros. Unfortunetely the <code>__shared_mutex_base</code> contains methods defined in a <code>.cpp</code> file. But internal <code>mutex</code> and <code>condition_variable</code> types are already default constexpr constructible and the <code>__shared_mutex_base</code> constructor only sets <code>__state_</code> to zero, so this constructor can be easily made <code>constexpr</code>.</p>
<p>All the single-threaded semantic can be then put into <code>shared_mutex</code> type, with <code>if consteval</code> and compiler builtin to attach constant evaluation metadata to an object.</p>
<pre class="lang-cpp"><code>struct __shared_mutex_base {
  mutex __mut_;
  condition_variable __gate1_;
  condition_variable __gate2_;
  unsigned __state_<span class="added">{0}</span>;

  static const unsigned __write_entered_ = 1U &lt;&lt; (sizeof(unsigned) * __CHAR_BIT__ - 1);
  static const unsigned __n_readers_     = ~__write_entered_;

  __shared_mutex_base() <span class="added">= default</span>;
  ~__shared_mutex_base() = default;

  __shared_mutex_base(const __shared_mutex_base&)            = delete;
  __shared_mutex_base& operator=(const __shared_mutex_base&) = delete;

  // Exclusive ownership
  void lock(); // blocking
  bool try_lock();
  void unlock();

  // Shared ownership
  void lock_shared(); // blocking
  bool try_lock_shared();
  void unlock_shared();
};
	
class shared_mutex {
  __shared_mutex_base __base_;

public:
  <span class="added">constexpr</span> shared_mutex() : __base_() {}
  ~shared_mutex() = default;

  shared_mutex(const shared_mutex&)            = delete;
  shared_mutex& operator=(const shared_mutex&) = delete;

  // Exclusive ownership
  <span class="added">constexpr</span> void lock() {
    <span class="added">if consteval {</span>
      <span class="added">return __builtin_metadata_unique_lock(&__base_);</span>
      <span class="added alt">if (__base_.state != 0) std::abort;</span>
      <span class="added alt">__base_.state = 1;</span>
    <span class="added">} else {</span>
      return __base_.lock();
    <span class="added">}</span>
  }
  <span class="added">constexpr</span> bool try_lock() {
    <span class="added">if consteval {</span>
      <span class="added">return __builtin_metadata_try_unique_lock(&__base_);</span>
      <span class="added alt">if (__base_.state != 0) return false;</span>
      <span class="added alt">__base_.state = 1;</span>
      <span class="added alt">return true;</span>
    <span class="added">} else {</span>
      return __base_.try_lock();
    <span class="added">}</span>
  }
  <span class="added">constexpr</span> void unlock() {
    <span class="added">if consteval {</span>
      <span class="added">return __builtin_metadata_unique_unlock(&__base_);</span>
      <span class="added alt">if (__base_.state != 1) std::abort();</span>
      <span class="added alt">__base_.state = 0;</span>
    <span class="added">} else {</span>
      return __base_.unlock();
    <span class="added">}</span>
  }

  // Shared ownership
  <span class="added">constexpr</span> void lock_shared() {
    <span class="added">if consteval {</span>
      <span class="added">return __builtin_metadata_shared_lock(&__base_);</span>
      <span class="added alt">if (__base_.state == 0) __base_.state = 2;</span>
      <span class="added alt">else if (__base_.state == 1) std::abort();</span>
      <span class="added alt">else ++__base_.state;</span>
    <span class="added">} else {</span>
      return __base_.lock_shared();
    <span class="added">}</span>
  }
  <span class="added">constexpr</span> bool try_lock_shared() {
    <span class="added">if consteval {</span>
      <span class="added">return __builtin_metadata_try_shared_lock(&__base_);</span>
      <span class="added alt">if (__base_.state == 0) __base_.state = 2;</span>
      <span class="added alt">else if (__base_.state == 1) return false;</span>
      <span class="added alt">else ++__base_.state;</span>
      <span class="added alt">return true;</span>
    <span class="added">} else {</span>
      return __base_.try_lock_shared();
    <span class="added">}</span>
  }
  <span class="added">constexpr</span> void unlock_shared() {
    <span class="added">if consteval {</span>
      <span class="added">return __builtin_metadata_shared_unlock(&__base_);</span>
      <span class="added alt">if (__base_.state == 0) std::abort();</span>
      <span class="added alt">else if (__base_.state == 1) std::abort();</span>
			<span class="added alt">else if (__base_.state == 2) __base_.state = 0;</span>
      <span class="added alt">else --__base_.state;</span>
    <span class="added">} else {</span>
      return __base_.unlock_shared();
    <span class="added">}</span>
  }
};</code></pre>
<p>Purposes of these builtins is to provided associated metadata to the object itself, and use them for useful diagnostics.</p>
<p>Alternative approach would be use <code>__shared_mutex_base::__state_</code> for it, and use library functionality to provide error messages in case of deadlock, but this approach doesn't allow us easily to diagnose where the lock was previously obtained.</p>
</section></section><section data-related="research-of-libstdc%2B%2B"><h3><a href="#research-of-libstdc%2B%2B" id="research-of-libstdc%2B%2B">Research of libstdc++</a></h3><p>Libstdc++ is supporting many platforms and code around synchronization primitives is somehow bit convoluted due macro abstractions and <code>#ifdef</code>-s rules to select appropriate implementation.</p>
<section data-related="std%3A%3Amutex"><h4><a href="#std%3A%3Amutex" id="std%3A%3Amutex">std::mutex</a></h4><p>Most basic mutex type is all defined in headers it's default constructor is defaulted or <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/bits/std_mutex.h#L104">explicitly made constexpr</a> in presence of macro <code>__GTHREAD_MUTEX_INIT</code>. Native type is hidden in <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/bits/std_mutex.h#L61-L84"><code>__mutex_base</code></a> which in order to support constexpr <em>default</em> initialize the <code>__gthread_mutex_t</code> native handle.</p>
</section><section data-related="std%3A%3Ashared-mutex"><h4><a href="#std%3A%3Ashared-mutex" id="std%3A%3Ashared-mutex">std::shared_mutex</a></h4><p>Shared mutex type's default constructor is not historically marked <code>constexpr</code>. It's also <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/std/shared_mutex#L416-L447">defined all in a header file</a>. Construction of native handle is abstract in <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/std/shared_mutex#L159-L264"><code>__shared_mutex_pthread</code></a> or <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/std/shared_mutex#L269-L410"><code>__shared_mutex_cv</code></a> which is used when platform doesn't provide <code>_GLIBCXX_USE_PTHREAD_RWLOCK_T</code> and its implementation is normal mutex and two condition variables, similarly as in libc++.</p>
<p>In case pthread of the platform provides RW lock, the type <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/std/shared_mutex#L159-L264"><code>__shared_mutex_pthread</code></a> abstracts it away. If macro <code>PTHREAD_RWLOCK_INITIALIZER</code> is available, it's used to defualt initialize the lock. This macro is on most major platform providing aggregate or numeric constant initialization (macOS, linux, win32's pthreads).</p>
</section><section data-related="lock-guards"><h4><a href="#lock-guards" id="lock-guards">lock guards</a></h4><p>All lock guards types (<a href="https://github.com/gcc-mirror/gcc/blob/6e24814d9e09019bf42b33b66827648ceff6e7c0/libstdc%2B%2B-v3/include/bits/std_mutex.h#L244-L266"><code>lock_guard</code></a>, <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/bits/unique_lock.h#L61-L240"><code>unique_lock</code></a>, <a href="https://github.com/gcc-mirror/gcc/blob/6e24814d9e09019bf42b33b66827648ceff6e7c0/libstdc%2B%2B-v3/include/std/shared_mutex#L732-L870"><code>shared_lock</code></a>, <a href="https://github.com/gcc-mirror/gcc/blob/9ff6ade24cae5a51d1ee9d9ad4b4a5c682e4a5ed/libstdc%2B%2B-v3/include/std/mutex#L745-L779"><code>scoped_lock</code></a>) are just RAII wrappers over interfaces of mutexes. There is nothing special and nothing which interfere with making them constexpr, these are already defined in header files.</p>
</section><section data-related="std%3A%3Acondition-variable"><h4><a href="#std%3A%3Acondition-variable" id="std%3A%3Acondition-variable">std::condition_variable</a></h4><p>Condition variable types are defined <a href="https://github.com/gcc-mirror/gcc/blob/6e24814d9e09019bf42b33b66827648ceff6e7c0/libstdc%2B%2B-v3/include/std/condition_variable#L72-L231">partially in header file</a>. Implementation of some function is in <a href="https://github.com/gcc-mirror/gcc/blob/6e24814d9e09019bf42b33b66827648ceff6e7c0/libstdc%2B%2B-v3/src/c%2B%2B11/condition_variable.cc#L34-L54">a source file</a> and they are not doing anything platform specific. Type <code>__condvar</code> which abstracts native handle is <a href="https://github.com/gcc-mirror/gcc/blob/6e24814d9e09019bf42b33b66827648ceff6e7c0/libstdc%2B%2B-v3/include/bits/std_mutex.h#L145-L212">defined next to std::mutex</a>. It doesn't contain same abstraction as was done for the mutex type, even when most pthread libraries provides equivalent macro <code>PTHREAD_COND_INITIALIZER</code> for constant initialization. This piece of code would benefit from update. Making <code>__condvar</code> <code>constexpr</code> compatible would be then trivial.</p>
</section></section><section data-related="ms-stl"><h3><a href="#ms-stl" id="ms-stl">MS STL</a></h3><p><a href="https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/mutex#L33-L117"><code>mutex</code>, <code>recursive_mutex</code>, and <code>timed_mutex</code> all share <code>_Mutex_base</code></a> and making these types <code>constexpr</code> will be trivial with <code>if consteval</code>. Same applies to <a href="https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/shared_mutex#L27-L65"><code>shared_mutex</code></a> too.</p>
<p>Type <a href="https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/mutex#L523-L598"><code>condition_variable</code></a> is defined in header, but it uses implementation function defined in source files. These can be circumvent easily with <code>if consteval</code>. There is a <code>_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR</code> macro, which optionaly disables <code>std::mutex</code>'s constructor and it makes the condition variable initialized with function defined outside. This is a deviation from the standard, and when this special macro is not set there is nothing which prevents condition variable to be <code>constexpr</code> compatible.</p>
</section></section><section data-related="wording"><h2><a href="#wording" id="wording">Wording</a></h2><section data-related="modify-constant-evaluation"><h3><a href="#modify-constant-evaluation" id="modify-constant-evaluation">Modify constant evaluation</a></h3><p>Purpose of this change is to disallow creation of already locked synchronization objects and their subsequent leakage into runtime code.</p>

<!-- expr.const.html (wording) -->
<div class="wording">
<h2 ><a class='secnum' style='min-width:65pt'>7.7</a> Constant expressions <a class='abbr_ref'>[expr.const]</a></h2><div class='para' id='10'><div class='marginalizedparent'><a class='marginalized' href='#10'>10</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/expressions.tex#L7942'>#</a></div><div class='texpara'><div id='10.sentence-1' class='sentence'>An expression <span class='math'><span class='mathalpha'>E</span></span> is a <a class='hidden_link' href='#def:expression,core_constant' title='7.7&emsp;Constant expressions&emsp;[expr.const]'><span id='def:expression,core_constant'><i >core constant expression</i></span></a>
unless the evaluation of <span class='math'><span class='mathalpha'>E</span></span>, following the rules of the abstract
machine (<a href='intro.execution' title='6.9.1&emsp;Sequential execution'>[intro.<span class='shy'></span>execution]</a>), would evaluate one of the following:
<ul class='itemize'><li id='10.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.1'>(10.1)</a></div><span id=':this'><span class='texttt'><span class='keyword'>this</span></span></span> (<a href='expr.prim.this' title='7.5.3&emsp;This'>[expr.<span class='shy'></span>prim.<span class='shy'></span>this]</a>), except
<ul class='itemize'><li id='10.1.1'><div class='marginalizedparent' style='left:-36mm'><a class='marginalized' href='#10.1.1'>(10.1.1)</a></div>in a constexpr function (<a href='dcl.constexpr' title='9.2.6&emsp;The constexpr and consteval specifiers'>[dcl.<span class='shy'></span>constexpr]</a>)
that is being evaluated as part of <span class='math'><span class='mathalpha'>E</span></span> or</li><li id='10.1.2'><div class='marginalizedparent' style='left:-36mm'><a class='marginalized' href='#10.1.2'>(10.1.2)</a></div>when appearing as the <a href='expr.post.general#nt:postfix-expression' title='7.6.1.1&emsp;General&emsp;[expr.post.general]'><span id='ntref:postfix-expression'><span class='textsf'><i >postfix-expression</i></span></span></a> of
an implicit or explicit class member access expression (<a href='expr.ref' title='7.6.1.5&emsp;Class member access'>[expr.<span class='shy'></span>ref]</a>);</li></ul></li><li id='10.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.2'>(10.2)</a></div>a control flow that passes through
a declaration of a block variable (<a href='basic.scope.block' title='6.4.3&emsp;Block scope'>[basic.<span class='shy'></span>scope.<span class='shy'></span>block]</a>) with
static (<a href='basic.stc.static' title='6.7.6.2&emsp;Static storage duration'>[basic.<span class='shy'></span>stc.<span class='shy'></span>static]</a>) or
thread (<a href='basic.stc.thread' title='6.7.6.3&emsp;Thread storage duration'>[basic.<span class='shy'></span>stc.<span class='shy'></span>thread]</a>) storage duration,
unless that variable is usable in constant expressions;
<div id='example-4' class='example'><div class='texpara'>[<i>Example&nbsp;<a href='#example-4'>4</a></i>:&ensp;<span class='codeblock'><span class='keyword'>constexpr</span> <span class='keyword'>char</span> test<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  <span class='keyword'>static</span> <span class='keyword'>const</span> <span class='keyword'>int</span> x <span class='operator'>=</span> <span class='literal'>5</span>;
  <span class='keyword'>static</span> <span class='keyword'>constexpr</span> <span class='keyword'>char</span> c<span class='squarebracket'>[</span><span class='squarebracket'>]</span> <span class='operator'>=</span> <span class='literal'>"Hello World"</span>;
  <span class='keyword'>return</span> <span class='operator'>*</span><span class='parenthesis'>(</span>c <span class='operator'>+</span> x<span class='parenthesis'>)</span>;
<span class='curlybracket'>}</span>
<span class='keyword'>static_assert</span><span class='parenthesis'>(</span><span class='literal'>' '</span> <span class='operator'>=</span><span class='operator'>=</span> test<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>;
</span> —&nbsp;<i>end example</i>]</div></div></li><li id='10.3'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.3'>(10.3)</a></div>an invocation of a non-constexpr function;<a class='footnoteref' href='#footnote-67' id='footnoteref-67' title='Overload resolution ([over.match]) is applied as usual.'>67</a></li><li id='10.4'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.4'>(10.4)</a></div>an invocation of an undefined constexpr function;</li><li id='10.5'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.5'>(10.5)</a></div>an invocation of an instantiated constexpr function
that is not constexpr-suitable;</li><li id='10.6'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.6'>(10.6)</a></div>an invocation of a virtual function (<a href='class.virtual' title='11.7.3&emsp;Virtual functions'>[class.<span class='shy'></span>virtual]</a>)
for an object whose dynamic type is constexpr-unknown;</li><li id='10.7'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.7'>(10.7)</a></div>an expression that would exceed the implementation-defined
limits (see <a href='implimits' title='Annex B&emsp;(informative)&emsp;Implementation quantities'>[implimits]</a>);</li><li id='10.8'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.8'>(10.8)</a></div>an operation that would have undefined or erroneous behavior
as specified in <a href='intro' title='4&emsp;General principles'>[intro]</a> through <a href='cpp' title='15&emsp;Preprocessing directives'>[cpp]</a>;<a class='footnoteref' href='#footnote-68' id='footnoteref-68' title='This includes, for example, signed integer overflow ([expr.pre]), certain pointer arithmetic ([expr.add]), division by zero ([expr.mul]), or certain shift operations ([expr.shift]).'>68</a></li><li id='10.9'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.9'>(10.9)</a></div>an <a href='conv.lval' title='7.3.2&emsp;Lvalue-to-rvalue conversion&emsp;[conv.lval]'>lvalue-to-rvalue conversion</a> unless
it is applied to
<ul class='itemize'><li id='10.9.1'><div class='marginalizedparent' style='left:-36mm'><a class='marginalized' href='#10.9.1'>(10.9.1)</a></div>a glvalue of type <span class='mathit'>cv</span> <span class='texttt'>std<span class='operator'>&#x200b;::&#x200b;</span>nullptr_<span class='shy'></span>t</span>,</li><li id='10.9.2'><div class='marginalizedparent' style='left:-36mm'><a class='marginalized' href='#10.9.2'>(10.9.2)</a></div>a non-volatile glvalue that refers to an object that is
  usable in constant expressions, or</li><li id='10.9.3'><div class='marginalizedparent' style='left:-36mm'><a class='marginalized' href='#10.9.3'>(10.9.3)</a></div>a non-volatile glvalue of literal type that refers to a non-volatile object
  whose lifetime began within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li></ul></li><li id='10.10'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.10'>(10.10)</a></div>an lvalue-to-rvalue conversion
that is applied to a glvalue
that refers to a non-active member of a union or a subobject thereof;</li><li id='10.11'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.11'>(10.11)</a></div>an lvalue-to-rvalue conversion that is applied to
an object with an <a href='basic.indet#def:value,indeterminate' title='6.7.5&emsp;Indeterminate and erroneous values&emsp;[basic.indet]'>indeterminate value</a>;</li><li id='10.12'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.12'>(10.12)</a></div>an invocation of an implicitly-defined copy/move constructor or
copy/move assignment operator
for a union whose active member (if any) is mutable,
unless the lifetime of the union object began within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li><li id='10.13'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.13'>(10.13)</a></div>in a <a href='expr.prim.lambda.general#nt:lambda-expression' title='7.5.6.1&emsp;General&emsp;[expr.prim.lambda.general]'><span id='ntref:lambda-expression'><span class='textsf'><i >lambda-expression</i></span></span></a>,
a reference to <span id=':this_'><span class='texttt'><span class='keyword'>this</span></span></span> or to a variable with
automatic storage duration defined outside that
<a href='expr.prim.lambda.general#nt:lambda-expression' title='7.5.6.1&emsp;General&emsp;[expr.prim.lambda.general]'><span id='ntref:lambda-expression_'><span class='textsf'><i >lambda-expression</i></span></span></a>, where
the reference would be an odr-use (<a href='basic.def.odr#term.odr.use' title='6.3&emsp;One-definition rule'>[basic.<span class='shy'></span>def.<span class='shy'></span>odr]</a>, <a href='expr.prim.lambda' title='7.5.6&emsp;Lambda expressions'>[expr.<span class='shy'></span>prim.<span class='shy'></span>lambda]</a>);
<div id='example-5' class='example'><div class='texpara'>[<i>Example&nbsp;<a href='#example-5'>5</a></i>:&ensp;<span class='codeblock'><span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  <span class='keyword'>const</span> <span class='keyword'>int</span> n <span class='operator'>=</span> <span class='literal'>0</span>;
  <span class='squarebracket'>[</span><span class='operator'>=</span><span class='squarebracket'>]</span> <span class='curlybracket'>{</span>
    <span class='keyword'>constexpr</span> <span class='keyword'>int</span> i <span class='operator'>=</span> n;        <span class='comment'>// OK, <span class='tcode_in_codeblock'>n</span> is not odr-used here</span>
    <span class='keyword'>constexpr</span> <span class='keyword'>int</span> j <span class='operator'>=</span> <span class='operator'>*</span><span class='operator'>&amp;</span>n;      <span class='comment'>// error: <span class='tcode_in_codeblock'>&amp;n</span> would be an odr-use of <span class='tcode_in_codeblock'>n</span></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span> —&nbsp;<i>end example</i>]</div></div>
<div id='note-4' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#note-4'>4</a></i>:&ensp;<div id='10.13.sentence-1' class='sentence'>If the odr-use occurs in an invocation
of a function call operator of a closure type,
it no longer refers to <span id=':this__'><span class='texttt'><span class='keyword'>this</span></span></span> or to an enclosing
variable with automatic storage duration
due to the transformation (<a href='expr.prim.lambda.capture' title='7.5.6.3&emsp;Captures'>[expr.<span class='shy'></span>prim.<span class='shy'></span>lambda.<span class='shy'></span>capture]</a>)
of the <a href='expr.prim.id.general#nt:id-expression' title='7.5.5.1&emsp;General&emsp;[expr.prim.id.general]'><span id='ntref:id-expression'><span class='textsf'><i >id-expression</i></span></span></a> into
an access of the corresponding data member<a class='hidden_link' href='#10.13.sentence-1'>.</a></div> <div id='example-6' class='example'><div class='texpara'>[<i>Example&nbsp;<a href='#example-6'>6</a></i>:&ensp;<span class='codeblock'><span class='keyword'>auto</span> monad <span class='operator'>=</span> <span class='squarebracket'>[</span><span class='squarebracket'>]</span><span class='parenthesis'>(</span><span class='keyword'>auto</span> v<span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='keyword'>return</span> <span class='squarebracket'>[</span><span class='operator'>=</span><span class='squarebracket'>]</span> <span class='curlybracket'>{</span> <span class='keyword'>return</span> v; <span class='curlybracket'>}</span>; <span class='curlybracket'>}</span>;
<span class='keyword'>auto</span> bind <span class='operator'>=</span> <span class='squarebracket'>[</span><span class='squarebracket'>]</span><span class='parenthesis'>(</span><span class='keyword'>auto</span> m<span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  <span class='keyword'>return</span> <span class='squarebracket'>[</span><span class='operator'>=</span><span class='squarebracket'>]</span><span class='parenthesis'>(</span><span class='keyword'>auto</span> fvm<span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='keyword'>return</span> fvm<span class='parenthesis'>(</span>m<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>; <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>;

<span class='comment'>// OK to capture objects with automatic storage duration created during constant expression evaluation.</span>
<span class='keyword'>static_assert</span><span class='parenthesis'>(</span>bind<span class='parenthesis'>(</span>monad<span class='parenthesis'>(</span><span class='literal'>2</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span><span class='parenthesis'>(</span>monad<span class='parenthesis'>)</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>=</span><span class='operator'>=</span> monad<span class='parenthesis'>(</span><span class='literal'>2</span><span class='parenthesis'>)</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>;
</span> —&nbsp;<i>end example</i>]</div></div> —&nbsp;<i>end note</i>]</div></div></li><li id='10.14'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.14'>(10.14)</a></div>a conversion
from a prvalue <span class='texttt'>P</span> of type “pointer to <span class='mathit'>cv</span> <span id=':void'><span class='texttt'><span class='keyword'>void</span></span></span>”
to a type “<i >cv1</i> pointer to  <span class='texttt'>T</span>”,
where  <span class='texttt'>T</span> is not <i >cv2</i> <span id=':void_'><span class='texttt'><span class='keyword'>void</span></span></span>,
unless <span class='texttt'>P</span>
is a null pointer value or
points to an object whose type is similar to <span class='texttt'>T</span>;</li><li id='10.15'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.15'>(10.15)</a></div>a <span id=':reinterpret_cast'><span class='texttt'><span class='keyword'>reinterpret_<span class='shy'></span>cast</span></span></span> (<a href='expr.reinterpret.cast' title='7.6.1.10&emsp;Reinterpret cast'>[expr.<span class='shy'></span>reinterpret.<span class='shy'></span>cast]</a>);</li><li id='10.16'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.16'>(10.16)</a></div>a modification of an object (<a href='expr.assign' title='7.6.19&emsp;Assignment and compound assignment operators'>[expr.<span class='shy'></span>assign]</a>, <a href='expr.post.incr' title='7.6.1.6&emsp;Increment and decrement'>[expr.<span class='shy'></span>post.<span class='shy'></span>incr]</a>, <a href='expr.pre.incr' title='7.6.2.3&emsp;Increment and decrement'>[expr.<span class='shy'></span>pre.<span class='shy'></span>incr]</a>)
unless it is applied to a non-volatile lvalue of literal type
that refers to a non-volatile object
whose lifetime began within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li><li id='10.17'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.17'>(10.17)</a></div>an invocation of a destructor (<a href='class.dtor' title='11.4.7&emsp;Destructors'>[class.<span class='shy'></span>dtor]</a>) or a function call
whose <a href='expr.post.general#nt:postfix-expression' title='7.6.1.1&emsp;General&emsp;[expr.post.general]'><span id='ntref:postfix-expression_'><span class='textsf'><i >postfix-expression</i></span></span></a> names a pseudo-destructor (<a href='expr.call' title='7.6.1.3&emsp;Function call'>[expr.<span class='shy'></span>call]</a>),
in either case for an object whose lifetime did not begin within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li><li id='10.18'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.18'>(10.18)</a></div>a <a href='expr.new#nt:new-expression' title='7.6.2.8&emsp;New&emsp;[expr.new]'><span id='ntref:new-expression'><span class='textsf'><i >new-expression</i></span></span></a> (<a href='expr.new' title='7.6.2.8&emsp;New'>[expr.<span class='shy'></span>new]</a>),
unless either
<ul class='itemize'><li id='10.18.1'><div class='marginalizedparent' style='left:-36mm'><a class='marginalized' href='#10.18.1'>(10.18.1)</a></div>the selected allocation function is
a replaceable global allocation function (<a href='new.delete.single' title='17.6.3.2&emsp;Single-object forms'>[new.<span class='shy'></span>delete.<span class='shy'></span>single]</a>, <a href='new.delete.array' title='17.6.3.3&emsp;Array forms'>[new.<span class='shy'></span>delete.<span class='shy'></span>array]</a>) and
the allocated storage is deallocated within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>, or</li><li id='10.18.2'><div class='marginalizedparent' style='left:-36mm'><a class='marginalized' href='#10.18.2'>(10.18.2)</a></div>the selected allocation function is
a non-allocating form (<a href='new.delete.placement' title='17.6.3.4&emsp;Non-allocating forms'>[new.<span class='shy'></span>delete.<span class='shy'></span>placement]</a>)
with an allocated type <span class='texttt'>T</span>, where
<ul class='itemize'><li id='10.18.2.1'><div class='marginalizedparent' style='left:-45mm'><a class='marginalized' href='#10.18.2.1'>(10.18.2.1)</a></div>the placement argument to the <a href='expr.new#nt:new-expression' title='7.6.2.8&emsp;New&emsp;[expr.new]'><span id='ntref:new-expression_'><span class='textsf'><i >new-expression</i></span></span></a> points to
an object whose type is similar to <span class='texttt'>T</span> (<a href='conv.qual' title='7.3.6&emsp;Qualification conversions'>[conv.<span class='shy'></span>qual]</a>) or,
if <span class='texttt'>T</span> is an array type,
to the first element of an object of a type similar to <span class='texttt'>T</span>, and</li><li id='10.18.2.2'><div class='marginalizedparent' style='left:-45mm'><a class='marginalized' href='#10.18.2.2'>(10.18.2.2)</a></div>the placement argument points to storage
whose duration began within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li></ul></li></ul></li><li id='10.19'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.19'>(10.19)</a></div>a <a href='expr.delete#nt:delete-expression' title='7.6.2.9&emsp;Delete&emsp;[expr.delete]'><span id='ntref:delete-expression'><span class='textsf'><i >delete-expression</i></span></span></a> (<a href='expr.delete' title='7.6.2.9&emsp;Delete'>[expr.<span class='shy'></span>delete]</a>),
unless it deallocates a region of storage
allocated within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li><li id='10.20'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.20'>(10.20)</a></div>a call to an instance of
<span class='texttt'>std<span class='operator'>&#x200b;::&#x200b;</span>allocator<span class='anglebracket'>&lt;</span>T<span class='anglebracket'>&gt;</span><span class='operator'>&#x200b;::&#x200b;</span>allocate</span> (<a href='allocator.members' title='20.2.10.2&emsp;Members'>[allocator.<span class='shy'></span>members]</a>),
unless the allocated storage is deallocated within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li><li id='10.21'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.21'>(10.21)</a></div>a call to an instance of
<span class='texttt'>std<span class='operator'>&#x200b;::&#x200b;</span>allocator<span class='anglebracket'>&lt;</span>T<span class='anglebracket'>&gt;</span><span class='operator'>&#x200b;::&#x200b;</span>deallocate</span> (<a href='allocator.members' title='20.2.10.2&emsp;Members'>[allocator.<span class='shy'></span>members]</a>),
unless it deallocates a region of storage
allocated within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li><li id='10.22'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.22'>(10.22)</a></div>a construction of an exception object,
unless the exception object and
all of its implicit copies created by invocations of
<span class='texttt'>std<span class='operator'>&#x200b;::&#x200b;</span>current_<span class='shy'></span>exception</span> or <span class='texttt'>std<span class='operator'>&#x200b;::&#x200b;</span>rethrow_<span class='shy'></span>exception</span> (<a href='propagation' title='17.9.7&emsp;Exception propagation'>[propagation]</a>)
are destroyed within the evaluation of <span class='math'><span class='mathalpha'>E</span></span>;</li>

<li id='10.qq' class="added"><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.qq'>(10.??)</a></div>a construction of a synchronization object [thread],
unless the object is destroyed within the evaluation of <span class='math'><span class='mathalpha'>E</span></span> or is in its default state when evaluation of <span class='math'><span class='mathalpha'>E</span></span> is finished;</li>

<li id='10.23'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.23'>(10.23)</a></div>an <a href='expr.await#nt:await-expression' title='7.6.2.4&emsp;Await&emsp;[expr.await]'><span id='ntref:await-expression'><span class='textsf'><i >await-expression</i></span></span></a> (<a href='expr.await' title='7.6.2.4&emsp;Await'>[expr.<span class='shy'></span>await]</a>);</li><li id='10.24'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.24'>(10.24)</a></div>a <a href='expr.yield#nt:yield-expression' title='7.6.17&emsp;Yielding a value&emsp;[expr.yield]'><span id='ntref:yield-expression'><span class='textsf'><i >yield-expression</i></span></span></a> (<a href='expr.yield' title='7.6.17&emsp;Yielding a value'>[expr.<span class='shy'></span>yield]</a>);</li><li id='10.25'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.25'>(10.25)</a></div>a three-way comparison (<a href='expr.spaceship' title='7.6.8&emsp;Three-way comparison operator'>[expr.<span class='shy'></span>spaceship]</a>),
relational (<a href='expr.rel' title='7.6.9&emsp;Relational operators'>[expr.<span class='shy'></span>rel]</a>), or equality (<a href='expr.eq' title='7.6.10&emsp;Equality operators'>[expr.<span class='shy'></span>eq]</a>)
operator where the result is unspecified;</li><li id='10.26'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.26'>(10.26)</a></div>a <span id=':dynamic_cast'><span class='texttt'><span class='keyword'>dynamic_<span class='shy'></span>cast</span></span></span> (<a href='expr.dynamic.cast' title='7.6.1.7&emsp;Dynamic cast'>[expr.<span class='shy'></span>dynamic.<span class='shy'></span>cast]</a>) or
<span id=':typeid'><span class='texttt'><span class='keyword'>typeid</span></span></span> (<a href='expr.typeid' title='7.6.1.8&emsp;Type identification'>[expr.<span class='shy'></span>typeid]</a>) expression
on a glvalue that refers to an object
whose dynamic type is constexpr-unknown;</li><li id='10.27'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.27'>(10.27)</a></div>a <span class='texttt'><span class='keyword'>dynamic_<span class='shy'></span>cast</span></span> (<a href='expr.dynamic.cast' title='7.6.1.7&emsp;Dynamic cast'>[expr.<span class='shy'></span>dynamic.<span class='shy'></span>cast]</a>) expression,
<span class='texttt'><span class='keyword'>typeid</span></span> (<a href='expr.typeid' title='7.6.1.8&emsp;Type identification'>[expr.<span class='shy'></span>typeid]</a>) expression, or
<span class='texttt'><span class='keyword'>new</span><span class='operator'>-</span>expression</span> (<a href='expr.new' title='7.6.2.8&emsp;New'>[expr.<span class='shy'></span>new]</a>)
that would throw an exception
where no definition of the exception type is reachable;</li><li id='10.28'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.28'>(10.28)</a></div>an <a href='dcl.asm#nt:asm-declaration' title='9.11&emsp;The asm declaration&emsp;[dcl.asm]'><span id='ntref:asm-declaration'><span class='textsf'><i >asm-declaration</i></span></span></a> (<a href='dcl.asm' title='9.11&emsp;The asm declaration'>[dcl.<span class='shy'></span>asm]</a>);</li><li id='10.29'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.29'>(10.29)</a></div>an invocation of the <span id='lib:va_arg'><span class='texttt'>va_<span class='shy'></span>arg</span></span> macro (<a href='cstdarg.syn' title='17.14.2&emsp;Header &lt;cstdarg&gt; synopsis'>[cstdarg.<span class='shy'></span>syn]</a>);</li><li id='10.30'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.30'>(10.30)</a></div>a non-constant library call (<a href='defns.nonconst.libcall' title='3.35&emsp;non-constant library call'>[defns.<span class='shy'></span>nonconst.<span class='shy'></span>libcall]</a>);
or</li><li id='10.31'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#10.31'>(10.31)</a></div>a <span id=':goto'><span class='texttt'><span class='keyword'>goto</span></span></span> statement (<a href='stmt.goto' title='8.7.6&emsp;The goto statement'>[stmt.<span class='shy'></span>goto]</a>)<a class='hidden_link' href='#10.sentence-1'>.</a> <div class='texpara'><div id='note-5' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#note-5'>5</a></i>:&ensp;<div id='10.31.sentence-2' class='sentence'>A <span id=':goto_'><span class='texttt'><span class='keyword'>goto</span></span></span> statement introduced by equivalence (<a href='stmt' title='8&emsp;Statements'>[stmt]</a>)
is not in scope<a class='hidden_link' href='#10.31.sentence-2'>.</a></div> <div id='10.31.sentence-3' class='sentence'>For example, a <span id=':while'><span class='texttt'><span class='keyword'>while</span></span></span> statement (<a href='stmt.while' title='8.6.2&emsp;The while statement'>[stmt.<span class='shy'></span>while]</a>)
can be executed during constant evaluation<a class='hidden_link' href='#10.31.sentence-3'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></li></ul></div></div></div>
</div>
</section><section data-related="mutexes-and-locking"><h3><a href="#mutexes-and-locking" id="mutexes-and-locking">Mutexes and locking</a></h3>
<!-- thread.mutex.html (wording) -->
<div class="wording">
<h2 ><a class='secnum' style='min-width:65pt'>32.6</a> Mutual exclusion <a class='abbr_ref'>[thread.mutex]</a></h2><div id='general' class='section'><h3 ><a class='secnum' href='#general' style='min-width:80pt'>32.6.1</a> General <a class='abbr_ref' href='thread.mutex.general'>[thread.mutex.general]</a></h3><div class='para' id='general-1'><div class='marginalizedparent'><a class='marginalized' href='#general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6512'>#</a></div><div class='texpara'><div id='general-1.sentence-1' class='sentence'>Subclause [thread.<span class='shy'></span>mutex] provides mechanisms for mutual exclusion: mutexes, locks, and call
once<a class='hidden_link' href='#general-1.sentence-1'>.</a></div> <div id='general-1.sentence-2' class='sentence'>These mechanisms ease the production of race-free
programs (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>)<a class='hidden_link' href='#general-1.sentence-2'>.</a></div></div></div></div><div id='mutex.syn' class='section'><h3 ><a class='secnum' href='#mutex.syn' style='min-width:80pt'>32.6.2</a> Header <span class='texttt'>&lt;mutex&gt;</span> synopsis <a class='abbr_ref' href='mutex.syn'>[mutex.syn]</a></h3><div class='texpara'><span id='header:<mutex>'><div class='marginalizedparent'><a class='itemDeclLink' href='#header:%3cmutex%3e'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='comment'>// <a href='#class' title='32.6.4.2.2&emsp;Class mutex'>[thread.<span class='shy'></span>mutex.<span class='shy'></span>class]</a>, class <span class='tcode_in_codeblock'>mutex</span></span>
  <span class='keyword'>class</span> mutex;
  <span class='comment'>// <a href='#recursive' title='32.6.4.2.3&emsp;Class recursive_&shy;mutex'>[thread.<span class='shy'></span>mutex.<span class='shy'></span>recursive]</a>, class <span class='tcode_in_codeblock'>recursive_<span class='shy'></span>mutex</span></span>
  <span class='keyword'>class</span> recursive_mutex;
  <span class='comment'>// <a href='#thread.timedmutex.class' title='32.6.4.3.2&emsp;Class timed_&shy;mutex'>[thread.<span class='shy'></span>timedmutex.<span class='shy'></span>class]</a>, class <span class='tcode_in_codeblock'>timed_<span class='shy'></span>mutex</span></span>
  <span class='keyword'>class</span> timed_mutex;
  <span class='comment'>// <a href='#thread.timedmutex.recursive' title='32.6.4.3.3&emsp;Class recursive_&shy;timed_&shy;mutex'>[thread.<span class='shy'></span>timedmutex.<span class='shy'></span>recursive]</a>, class <span class='tcode_in_codeblock'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span></span>
  <span class='keyword'>class</span> recursive_timed_mutex;

  <span class='keyword'>struct</span> defer_lock_t <span class='curlybracket'>{</span> <span class='keyword'>explicit</span> defer_lock_t<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>default</span>; <span class='curlybracket'>}</span>;
  <span class='keyword'>struct</span> try_to_lock_t <span class='curlybracket'>{</span> <span class='keyword'>explicit</span> try_to_lock_t<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>default</span>; <span class='curlybracket'>}</span>;
  <span class='keyword'>struct</span> adopt_lock_t <span class='curlybracket'>{</span> <span class='keyword'>explicit</span> adopt_lock_t<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>default</span>; <span class='curlybracket'>}</span>;

  <span class='keyword'>inline</span> <span class='keyword'>constexpr</span> defer_lock_t  defer_lock <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;
  <span class='keyword'>inline</span> <span class='keyword'>constexpr</span> try_to_lock_t try_to_lock <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;
  <span class='keyword'>inline</span> <span class='keyword'>constexpr</span> adopt_lock_t  adopt_lock <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;

  <span class='comment'>// <a href='#thread.lock' title='32.6.5&emsp;Locks'>[thread.<span class='shy'></span>lock]</a>, locks</span>
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span> <span class='keyword'>class</span> lock_guard;
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> MutexTypes<span class='anglebracket'>&gt;</span> <span class='keyword'>class</span> scoped_lock;
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span> <span class='keyword'>class</span> unique_lock;

  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> x, unique_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> y<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;

  <span class='comment'>// <a href='#thread.lock.algorithm' title='32.6.6&emsp;Generic locking algorithms'>[thread.<span class='shy'></span>lock.<span class='shy'></span>algorithm]</a>, generic locking algorithms</span>
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> L1, <span class='keyword'>class</span> L2, <span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> L3<span class='anglebracket'>&gt;</span> <span class='keyword'>int</span> try_lock<span class='parenthesis'>(</span>L1<span class='operator'>&amp;</span>, L2<span class='operator'>&amp;</span>, L3<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span>;
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> L1, <span class='keyword'>class</span> L2, <span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> L3<span class='anglebracket'>&gt;</span> <span class='keyword'>void</span> lock<span class='parenthesis'>(</span>L1<span class='operator'>&amp;</span>, L2<span class='operator'>&amp;</span>, L3<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span>;

  <span class='keyword'>struct</span> once_flag;

  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Callable, <span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> Args<span class='anglebracket'>&gt;</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> call_once<span class='parenthesis'>(</span>once_flag<span class='operator'>&amp;</span> flag, Callable<span class='operator'>&amp;</span><span class='operator'>&amp;</span> func, Args<span class='operator'>&amp;</span><span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> args<span class='parenthesis'>)</span>;
<span class='curlybracket'>}</span>
</span></span></div></div><div id='shared.mutex.syn' class='section'><h3 ><a class='secnum' href='#shared.mutex.syn' style='min-width:80pt'>32.6.3</a> Header <span class='texttt'>&lt;shared_<span class='shy'></span>mutex&gt;</span> synopsis <a class='abbr_ref' href='shared.mutex.syn'>[shared.mutex.syn]</a></h3><div class='texpara'><span id='header:<shared_mutex>'><div class='marginalizedparent'><a class='itemDeclLink' href='#header:%3cshared_mutex%3e'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='comment'>// <a href='#thread.sharedmutex.class' title='32.6.4.4.2&emsp;Class shared_&shy;mutex'>[thread.<span class='shy'></span>sharedmutex.<span class='shy'></span>class]</a>, class <span class='tcode_in_codeblock'>shared_<span class='shy'></span>mutex</span></span>
  <span class='keyword'>class</span> shared_mutex;
  <span class='comment'>// <a href='#thread.sharedtimedmutex.class' title='32.6.4.5.2&emsp;Class shared_&shy;timed_&shy;mutex'>[thread.<span class='shy'></span>sharedtimedmutex.<span class='shy'></span>class]</a>, class <span class='tcode_in_codeblock'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span></span>
  <span class='keyword'>class</span> shared_timed_mutex;
  <span class='comment'>// <a href='#thread.lock.shared' title='32.6.5.5&emsp;Class template shared_&shy;lock'>[thread.<span class='shy'></span>lock.<span class='shy'></span>shared]</a>, class template <span class='tcode_in_codeblock'>shared_<span class='shy'></span>lock</span></span>
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span> <span class='keyword'>class</span> shared_lock;
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>shared_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> x, shared_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> y<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
<span class='curlybracket'>}</span>
</span></span></div></div><div id='requirements' class='section'><h3 ><a class='secnum' href='#requirements' style='min-width:80pt'>32.6.4</a> Mutex requirements <a class='abbr_ref' href='thread.mutex.requirements'>[thread.mutex.requirements]</a></h3><div id='requirements.general' class='section'><h4 ><a class='secnum' href='#requirements.general' style='min-width:95pt'>32.6.4.1</a> General <a class='abbr_ref' href='thread.mutex.requirements.general'>[thread.mutex.requirements.general]</a></h4><div class='para' id='requirements.general-1'><div class='marginalizedparent'><a class='marginalized' href='#requirements.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6578'>#</a></div><div class='texpara'><div id='requirements.general-1.sentence-1' class='sentence'>A mutex object facilitates protection against data races and allows safe synchronization of
data between <a href='thread.req.lockable#def:execution_agent' title='32.2.5&emsp;Requirements for Cpp17Lockable types&emsp;[thread.req.lockable]'>execution agents</a><a class='hidden_link' href='#requirements.general-1.sentence-1'>.</a></div> <div id='requirements.general-1.sentence-2' class='sentence'>An execution agent <a class='hidden_link' href='#def:owns' id='def:owns'><i>owns</i></a> a mutex from the time it successfully calls one of the
lock functions until it calls unlock<a class='hidden_link' href='#requirements.general-1.sentence-2'>.</a></div> <div id='requirements.general-1.sentence-3' class='sentence'>Mutexes can be either recursive or non-recursive, and can
grant simultaneous ownership to one or many execution agents<a class='hidden_link' href='#requirements.general-1.sentence-3'>.</a></div> <div id='requirements.general-1.sentence-4' class='sentence'>Both
recursive and non-recursive mutexes are supplied<a class='hidden_link' href='#requirements.general-1.sentence-4'>.</a></div></div></div></div><div id='requirements.mutex' class='section'><h4 ><a class='secnum' href='#requirements.mutex' style='min-width:95pt'>32.6.4.2</a> Mutex types <a class='abbr_ref' href='thread.mutex.requirements.mutex'>[thread.mutex.requirements.mutex]</a></h4><div id='requirements.mutex.general' class='section'><h4 ><a class='secnum' href='#requirements.mutex.general' style='min-width:110pt'>32.6.4.2.1</a> General <a class='abbr_ref' href='thread.mutex.requirements.mutex.general'>[thread.mutex.requirements.mutex.general]</a></h4><div class='para' id='requirements.mutex.general-1'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6590'>#</a></div><div class='texpara'><div id='requirements.mutex.general-1.sentence-1' class='sentence'>The <a class='hidden_link' href='#def:mutex_types' title='32.6.4.2.1&emsp;General&emsp;[thread.mutex.requirements.mutex.general]'><span id='def:mutex_types'><i >mutex types</i></span></a> are the standard library types <span class='texttt'>mutex</span>,
<span class='texttt'>recursive_<span class='shy'></span>mutex</span>, <span class='texttt'>timed_<span class='shy'></span>mutex</span>, <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>,
<span class='texttt'>shared_<span class='shy'></span>mutex</span>, and <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span><a class='hidden_link' href='#requirements.mutex.general-1.sentence-1'>.</a></div> <div id='requirements.mutex.general-1.sentence-2' class='sentence'>They meet the requirements set out in <a href='#requirements.mutex' title='32.6.4.2&emsp;Mutex types'>[thread.<span class='shy'></span>mutex.<span class='shy'></span>requirements.<span class='shy'></span>mutex]</a><a class='hidden_link' href='#requirements.mutex.general-1.sentence-2'>.</a></div> <div id='requirements.mutex.general-1.sentence-3' class='sentence'>In this description, <span class='texttt'>m</span> denotes an object of a mutex type<a class='hidden_link' href='#requirements.mutex.general-1.sentence-3'>.</a></div> <div id='requirements.mutex.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#requirements.mutex.general-note-1'>1</a></i>:&ensp;<div id='requirements.mutex.general-1.sentence-4' class='sentence'>The mutex types meet the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a> requirements (<a href='thread.req.lockable.req' title='32.2.5.3&emsp;Cpp17Lockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>req]</a>)<a class='hidden_link' href='#requirements.mutex.general-1.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='requirements.mutex.general-2'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6600'>#</a></div><div class='texpara'><div id='requirements.mutex.general-2.sentence-1' class='sentence'>The mutex types meet <a href='utility.arg.requirements#:Cpp17DefaultConstructible' title='16.4.4.2&emsp;Template argument requirements&emsp;[utility.arg.requirements]'><i >Cpp17DefaultConstructible</i></a> and <a href='utility.arg.requirements#:Cpp17Destructible' title='16.4.4.2&emsp;Template argument requirements&emsp;[utility.arg.requirements]'><i >Cpp17Destructible</i></a><a class='hidden_link' href='#requirements.mutex.general-2.sentence-1'>.</a></div> <div id='requirements.mutex.general-2.sentence-2' class='sentence'>If initialization of an object of a mutex type fails,
an exception of type <span class='texttt'>system_<span class='shy'></span>error</span> is thrown<a class='hidden_link' href='#requirements.mutex.general-2.sentence-2'>.</a></div> <div id='requirements.mutex.general-2.sentence-3' class='sentence'>The mutex types are neither copyable nor movable<a class='hidden_link' href='#requirements.mutex.general-2.sentence-3'>.</a></div></div></div><div class='para' id='requirements.mutex.general-3'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6606'>#</a></div><div class='texpara'><div id='requirements.mutex.general-3.sentence-1' class='sentence'>The error conditions for error codes, if any, reported by member functions of the mutex types
are as follows:
<ul class='itemize'><li id='requirements.mutex.general-3.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#requirements.mutex.general-3.1'>(3.1)</a></div><div class='texpara'><div id='requirements.mutex.general-3.1.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>unavailable_<span class='shy'></span>try_<span class='shy'></span>again</span> — if any native handle type manipulated is not available<a class='hidden_link' href='#requirements.mutex.general-3.1.sentence-1'>.</a></div></div></li><li id='requirements.mutex.general-3.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#requirements.mutex.general-3.2'>(3.2)</a></div><div class='texpara'><div id='requirements.mutex.general-3.2.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if the thread does not have the
privilege to perform the operation<a class='hidden_link' href='#requirements.mutex.general-3.2.sentence-1'>.</a></div></div></li><li id='requirements.mutex.general-3.3'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#requirements.mutex.general-3.3'>(3.3)</a></div><div class='texpara'><div id='requirements.mutex.general-3.3.sentence-1' class='sentence'><span class='texttt'>invalid_<span class='shy'></span>argument</span> — if any native handle type manipulated as part of mutex
construction is incorrect<a class='hidden_link' href='#requirements.mutex.general-3.3.sentence-1'>.</a></div></div></li></ul></div></div></div><div class='para' id='requirements.mutex.general-4'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6617'>#</a></div><div class='texpara'><div id='requirements.mutex.general-4.sentence-1' class='sentence'>The implementation provides lock and unlock operations, as described below<a class='hidden_link' href='#requirements.mutex.general-4.sentence-1'>.</a></div> <div id='requirements.mutex.general-4.sentence-2' class='sentence'>For purposes of determining the existence of a data race, these behave as
atomic operations (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>)<a class='hidden_link' href='#requirements.mutex.general-4.sentence-2'>.</a></div> <div id='requirements.mutex.general-4.sentence-3' class='sentence'>The lock and unlock operations on
a single mutex appears to occur in a single total order<a class='hidden_link' href='#requirements.mutex.general-4.sentence-3'>.</a></div> <div id='requirements.mutex.general-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#requirements.mutex.general-note-2'>2</a></i>:&ensp;<div id='requirements.mutex.general-4.sentence-4' class='sentence'>This
can be viewed as the <a href='intro.multithread#def:modification_order' title='6.9.2&emsp;Multi-threaded executions and data races&emsp;[intro.multithread]'>modification order</a> of the
mutex<a class='hidden_link' href='#requirements.mutex.general-4.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div> <div id='requirements.mutex.general-note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#requirements.mutex.general-note-3'>3</a></i>:&ensp;<div id='requirements.mutex.general-4.sentence-5' class='sentence'>Construction and
destruction of an object of a mutex type need not be thread-safe; other
synchronization can be used to ensure that mutex objects are initialized
and visible to other threads<a class='hidden_link' href='#requirements.mutex.general-4.sentence-5'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='requirements.mutex.general-5'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-5'>5</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6634'>#</a></div><div class='texpara'><div id='requirements.mutex.general-5.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is well-formed and has the following semantics:</div></div></div><div class='para' id='requirements.mutex.general-6'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6637'>#</a></div><div class='texpara'><div id='requirements.mutex.general-6.sentence-1' class='sentence'><i >Preconditions</i>: If <span class='texttt'>m</span> is of type <span class='texttt'>mutex</span>, <span class='texttt'>timed_<span class='shy'></span>mutex</span>,
<span class='texttt'>shared_<span class='shy'></span>mutex</span>, or <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>, the calling
thread does not own the mutex<a class='hidden_link' href='#requirements.mutex.general-6.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-7'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6643'>#</a></div><div class='texpara'><div id='requirements.mutex.general-7.sentence-1' class='sentence'><a class='index' id=':block_(execution)'></a><i >Effects</i>: Blocks the calling thread until ownership of the mutex can be obtained for the calling thread<a class='hidden_link' href='#requirements.mutex.general-7.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-8'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6648'>#</a></div><div class='texpara'><div id='requirements.mutex.general-8.sentence-1' class='sentence'><i >Synchronization</i>: Prior <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> operations on the same object
<a class='hidden_link' href='#def:synchronize_with' id='def:synchronize_with'><i>synchronize with</i></a> (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>) this operation<a class='hidden_link' href='#requirements.mutex.general-8.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-9'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6653'>#</a></div><div class='texpara'><div id='requirements.mutex.general-9.sentence-1' class='sentence'><i >Postconditions</i>: The calling thread owns the mutex<a class='hidden_link' href='#requirements.mutex.general-9.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-10'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6657'>#</a></div><div class='texpara'><div id='requirements.mutex.general-10.sentence-1' class='sentence'><i >Return type</i>: <span id=':void'><span class='texttt'><span class='keyword'>void</span></span></span><a class='hidden_link' href='#requirements.mutex.general-10.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-11'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6660'>#</a></div><div class='texpara'><div id='requirements.mutex.general-11.sentence-1' class='sentence'><i >Throws</i>: <span class='texttt'>system_<span class='shy'></span>error</span> when
an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#requirements.mutex.general-11.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-12'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6665'>#</a></div><div class='texpara'><div id='requirements.mutex.general-12.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='requirements.mutex.general-12.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#requirements.mutex.general-12.1'>(12.1)</a></div><div class='texpara'><div id='requirements.mutex.general-12.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if the thread does not have the
privilege to perform the operation<a class='hidden_link' href='#requirements.mutex.general-12.1.sentence-1'>.</a></div></div></li><li id='requirements.mutex.general-12.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#requirements.mutex.general-12.2'>(12.2)</a></div><div class='texpara'><div id='requirements.mutex.general-12.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if the implementation detects
that a deadlock would occur<a class='hidden_link' href='#requirements.mutex.general-12.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='para' id='requirements.mutex.general-13'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-13'>13</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6676'>#</a></div><div class='texpara'><div id='requirements.mutex.general-13.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is well-formed and has the following semantics:</div></div></div><div class='para' id='requirements.mutex.general-14'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6679'>#</a></div><div class='texpara'><div id='requirements.mutex.general-14.sentence-1' class='sentence'><i >Preconditions</i>: If <span class='texttt'>m</span> is of type <span class='texttt'>mutex</span>, <span class='texttt'>timed_<span class='shy'></span>mutex</span>,
<span class='texttt'>shared_<span class='shy'></span>mutex</span>, or <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>, the calling
thread does not own the mutex<a class='hidden_link' href='#requirements.mutex.general-14.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-15'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6685'>#</a></div><div class='texpara'><div id='requirements.mutex.general-15.sentence-1' class='sentence'><i >Effects</i>: Attempts to obtain ownership of the mutex for the calling thread without
blocking<a class='hidden_link' href='#requirements.mutex.general-15.sentence-1'>.</a></div> <div id='requirements.mutex.general-15.sentence-2' class='sentence'>If ownership is not obtained, there is no effect and <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
immediately returns<a class='hidden_link' href='#requirements.mutex.general-15.sentence-2'>.</a></div> <div id='requirements.mutex.general-15.sentence-3' class='sentence'>An implementation may fail to obtain the lock even if it is not
held by any other thread<a class='hidden_link' href='#requirements.mutex.general-15.sentence-3'>.</a></div> <div id='requirements.mutex.general-note-4' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#requirements.mutex.general-note-4'>4</a></i>:&ensp;<div id='requirements.mutex.general-15.sentence-4' class='sentence'>This spurious failure is normally uncommon, but
allows interesting implementations based on a simple
compare and exchange (<a href='atomics' title='32.5&emsp;Atomic operations'>[atomics]</a>)<a class='hidden_link' href='#requirements.mutex.general-15.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div> <div id='requirements.mutex.general-15.sentence-5' class='sentence'>
An implementation should ensure that <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> does not consistently return <span class='texttt'><span class='literal'>false</span></span>
in the absence of contending mutex acquisitions<a class='hidden_link' href='#requirements.mutex.general-15.sentence-5'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-16'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6699'>#</a></div><div class='texpara'><div id='requirements.mutex.general-16.sentence-1' class='sentence'><i >Synchronization</i>: If <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns <span class='texttt'><span class='literal'>true</span></span>, prior <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> operations
on the same object <a href='intro.multithread#def:synchronize_with' title='6.9.2&emsp;Multi-threaded executions and data races&emsp;[intro.multithread]'>synchronize with</a> this operation<a class='hidden_link' href='#requirements.mutex.general-16.sentence-1'>.</a></div> <div id='requirements.mutex.general-note-5' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#requirements.mutex.general-note-5'>5</a></i>:&ensp;<div id='requirements.mutex.general-16.sentence-2' class='sentence'>Since <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> does not synchronize with a failed subsequent
<span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, the visibility rules are weak enough that little would be
known about the state after a failure, even in the absence of spurious failures<a class='hidden_link' href='#requirements.mutex.general-16.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='requirements.mutex.general-17'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-17'>17</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6709'>#</a></div><div class='texpara'><div id='requirements.mutex.general-17.sentence-1' class='sentence'><i >Return type</i>: <span class='texttt'><span class='keyword'>bool</span></span><a class='hidden_link' href='#requirements.mutex.general-17.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-18'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6712'>#</a></div><div class='texpara'><div id='requirements.mutex.general-18.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='literal'>true</span></span> if ownership was obtained, otherwise <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#requirements.mutex.general-18.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-19'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-19'>19</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6716'>#</a></div><div class='texpara'><div id='requirements.mutex.general-19.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#requirements.mutex.general-19.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-20'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-20'>20</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6721'>#</a></div><div class='texpara'><div id='requirements.mutex.general-20.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is well-formed and has the following semantics:</div></div></div><div class='para' id='requirements.mutex.general-21'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-21'>21</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6724'>#</a></div><div class='texpara'><div id='requirements.mutex.general-21.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread owns the mutex<a class='hidden_link' href='#requirements.mutex.general-21.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-22'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-22'>22</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6728'>#</a></div><div class='texpara'><div id='requirements.mutex.general-22.sentence-1' class='sentence'><i >Effects</i>: Releases the calling thread's ownership of the mutex<a class='hidden_link' href='#requirements.mutex.general-22.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-23'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-23'>23</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6732'>#</a></div><div class='texpara'><div id='requirements.mutex.general-23.sentence-1' class='sentence'><i >Return type</i>: <span id=':void_'><span class='texttt'><span class='keyword'>void</span></span></span><a class='hidden_link' href='#requirements.mutex.general-23.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-24'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-24'>24</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6735'>#</a></div><div class='texpara'><div id='requirements.mutex.general-24.sentence-1' class='sentence'><i >Synchronization</i>: This operation <a href='intro.multithread#def:synchronize_with' title='6.9.2&emsp;Multi-threaded executions and data races&emsp;[intro.multithread]'>synchronizes with</a> subsequent
lock operations that obtain ownership on the same object<a class='hidden_link' href='#requirements.mutex.general-24.sentence-1'>.</a></div></div></div></div><div class='para' id='requirements.mutex.general-25'><div class='marginalizedparent'><a class='marginalized' href='#requirements.mutex.general-25'>25</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6740'>#</a></div><div class='texpara'><div id='requirements.mutex.general-25.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#requirements.mutex.general-25.sentence-1'>.</a></div></div></div></div></div><div id='class' class='section'><h4 ><a class='secnum' href='#class' style='min-width:110pt'>32.6.4.2.2</a> Class <span class='texttt'>mutex</span> <a class='abbr_ref' href='thread.mutex.class'>[thread.mutex.class]</a></h4><div class='texpara'><span id='lib:mutex'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:mutex'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> mutex <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class='keyword'>constexpr</span> mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    mutex<span class='parenthesis'>(</span><span class='keyword'>const</span> mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    mutex<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='keyword'>using</span> native_handle_type <span class='operator'>=</span> <i >implementation-defined</i>;          <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
    native_handle_type native_handle<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                         <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='class-1'><div class='marginalizedparent'><a class='marginalized' href='#class-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6768'>#</a></div><div class='texpara'><div id='class-1.sentence-1' class='sentence'><a class='index' id=':block_(execution)_'></a>The class <span class='texttt'>mutex</span> provides a non-recursive mutex with exclusive ownership
semantics<a class='hidden_link' href='#class-1.sentence-1'>.</a></div> <div id='class-1.sentence-2' class='sentence'>If one thread owns a mutex object, attempts by another thread to acquire
ownership of that object will fail (for <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) or block (for
<span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) until the owning thread has released ownership with a call to
<span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#class-1.sentence-2'>.</a></div></div></div><div class='para nonNormativeOnly' id='class-2'><div class='marginalizedparent'><a class='marginalized' href='#class-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6776'>#</a></div><div class='texpara'><div id='class-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#class-note-1'>1</a></i>:&ensp;<div id='class-2.sentence-1' class='sentence'>After a thread <span class='texttt'>A</span> has called <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, releasing a mutex, it is possible for another
thread <span class='texttt'>B</span> to lock the same mutex, observe that it is no longer in use, unlock it, and
destroy it, before thread <span class='texttt'>A</span> appears to have returned from its unlock call<a class='hidden_link' href='#class-2.sentence-1'>.</a></div> <div id='class-2.sentence-2' class='sentence'>Conforming implementations
handle such scenarios correctly, as long as thread <span class='texttt'>A</span> does not access the
mutex after the unlock call returns<a class='hidden_link' href='#class-2.sentence-2'>.</a></div> <div id='class-2.sentence-3' class='sentence'>These cases typically occur when a reference-counted object
contains a mutex that is used to protect the reference count<a class='hidden_link' href='#class-2.sentence-3'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='class-3'><div class='marginalizedparent'><a class='marginalized' href='#class-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6786'>#</a></div><div class='texpara'><div id='class-3.sentence-1' class='sentence'>The class <span class='texttt'>mutex</span> meets
all of the mutex requirements (<a href='#requirements' title='32.6.4&emsp;Mutex requirements'>[thread.<span class='shy'></span>mutex.<span class='shy'></span>requirements]</a>)<a class='hidden_link' href='#class-3.sentence-1'>.</a></div> <div id='class-3.sentence-2' class='sentence'>It is a standard-layout class (<a href='class.prop' title='11.2&emsp;Properties of classes'>[class.<span class='shy'></span>prop]</a>)<a class='hidden_link' href='#class-3.sentence-2'>.</a></div></div></div><div class='para nonNormativeOnly' id='class-4'><div class='marginalizedparent'><a class='marginalized' href='#class-4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6791'>#</a></div><div class='texpara'><div id='class-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#class-note-2'>2</a></i>:&ensp;<div id='class-4.sentence-1' class='sentence'>A program can deadlock if the thread that owns a <span class='texttt'>mutex</span> object calls
<span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> on that object<a class='hidden_link' href='#class-4.sentence-1'>.</a></div> <div id='class-4.sentence-2' class='sentence'>If the implementation can detect the deadlock,
a <span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> error condition might be observed<a class='hidden_link' href='#class-4.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='class-5'><div class='marginalizedparent'><a class='marginalized' href='#class-5'>5</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6798'>#</a></div><div class='texpara'><div id='class-5.sentence-1' class='sentence'>The behavior of a program is undefined if
it destroys a <span class='texttt'>mutex</span> object owned by any thread or
a thread terminates while owning a <span class='texttt'>mutex</span> object<a class='hidden_link' href='#class-5.sentence-1'>.</a></div></div></div></div><div id='recursive' class='section'><h4 ><a class='secnum' href='#recursive' style='min-width:110pt'>32.6.4.2.3</a> Class <span class='texttt'>recursive_<span class='shy'></span>mutex</span> <a class='abbr_ref' href='thread.mutex.recursive'>[thread.mutex.recursive]</a></h4><div class='texpara'><span id='lib:recursive_mutex'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:recursive_mutex'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> recursive_mutex <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class="added">constexpr </span>recursive_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>recursive_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    recursive_mutex<span class='parenthesis'>(</span><span class='keyword'>const</span> recursive_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    recursive_mutex<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> recursive_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='keyword'>using</span> native_handle_type <span class='operator'>=</span> <i >implementation-defined</i>;          <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
    native_handle_type native_handle<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                         <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='recursive-1'><div class='marginalizedparent'><a class='marginalized' href='#recursive-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6826'>#</a></div><div class='texpara'><div id='recursive-1.sentence-1' class='sentence'><a class='index' id=':block_(execution)__'></a>The class <span class='texttt'>recursive_<span class='shy'></span>mutex</span> provides a recursive mutex with exclusive ownership
semantics<a class='hidden_link' href='#recursive-1.sentence-1'>.</a></div> <div id='recursive-1.sentence-2' class='sentence'>If one thread owns a <span class='texttt'>recursive_<span class='shy'></span>mutex</span> object, attempts by another
thread to acquire ownership of that object will fail (for <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) or block
(for <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) until the first thread has completely released ownership<a class='hidden_link' href='#recursive-1.sentence-2'>.</a></div></div></div><div class='para' id='recursive-2'><div class='marginalizedparent'><a class='marginalized' href='#recursive-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6833'>#</a></div><div class='texpara'><div id='recursive-2.sentence-1' class='sentence'>The class <span class='texttt'>recursive_<span class='shy'></span>mutex</span> meets
all of the mutex requirements (<a href='#requirements' title='32.6.4&emsp;Mutex requirements'>[thread.<span class='shy'></span>mutex.<span class='shy'></span>requirements]</a>)<a class='hidden_link' href='#recursive-2.sentence-1'>.</a></div> <div id='recursive-2.sentence-2' class='sentence'>It is a standard-layout class (<a href='class.prop' title='11.2&emsp;Properties of classes'>[class.<span class='shy'></span>prop]</a>)<a class='hidden_link' href='#recursive-2.sentence-2'>.</a></div></div></div><div class='para' id='recursive-3'><div class='marginalizedparent'><a class='marginalized' href='#recursive-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6838'>#</a></div><div class='texpara'><div id='recursive-3.sentence-1' class='sentence'>A thread that owns a <span class='texttt'>recursive_<span class='shy'></span>mutex</span> object may acquire additional levels of
ownership by calling <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> or <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> on that object<a class='hidden_link' href='#recursive-3.sentence-1'>.</a></div> <div id='recursive-3.sentence-2' class='sentence'>It is
unspecified how many levels of ownership may be acquired by a single thread<a class='hidden_link' href='#recursive-3.sentence-2'>.</a></div> <div id='recursive-3.sentence-3' class='sentence'>If a thread
has already acquired the maximum level of ownership for a <span class='texttt'>recursive_<span class='shy'></span>mutex</span>
object, additional calls to <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> fail, and additional calls to
<span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> throw an exception of type <span class='texttt'>system_<span class='shy'></span>error</span><a class='hidden_link' href='#recursive-3.sentence-3'>.</a></div> <div id='recursive-3.sentence-4' class='sentence'>A thread
shall call <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> once for each level of ownership acquired by calls to
<span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> and <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#recursive-3.sentence-4'>.</a></div> <div id='recursive-3.sentence-5' class='sentence'>Only when all levels of ownership have been
released may ownership be acquired by another thread<a class='hidden_link' href='#recursive-3.sentence-5'>.</a></div></div></div><div class='para' id='recursive-4'><div class='marginalizedparent'><a class='marginalized' href='#recursive-4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6849'>#</a></div><div class='texpara'><div id='recursive-4.sentence-1' class='sentence'>The behavior of a program is undefined if
<ul class='itemize'><li id='recursive-4.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#recursive-4.1'>(4.1)</a></div>it destroys a <span class='texttt'>recursive_<span class='shy'></span>mutex</span> object owned by any thread or</li><li id='recursive-4.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#recursive-4.2'>(4.2)</a></div>a thread terminates while owning a <span class='texttt'>recursive_<span class='shy'></span>mutex</span> object<a class='hidden_link' href='#recursive-4.sentence-1'>.</a></li></ul></div></div></div></div></div><div id='thread.timedmutex.requirements' class='section'><h4 ><a class='secnum' href='#thread.timedmutex.requirements' style='min-width:95pt'>32.6.4.3</a> Timed mutex types <a class='abbr_ref' href='thread.timedmutex.requirements'>[thread.timedmutex.requirements]</a></h4><div id='thread.timedmutex.requirements.general' class='section'><h4 ><a class='secnum' href='#thread.timedmutex.requirements.general' style='min-width:110pt'>32.6.4.3.1</a> General <a class='abbr_ref' href='thread.timedmutex.requirements.general'>[thread.timedmutex.requirements.general]</a></h4><div class='para' id='thread.timedmutex.requirements.general-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6860'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-1.sentence-1' class='sentence'>The <a class='hidden_link' href='#def:timed_mutex_types' title='32.6.4.3.1&emsp;General&emsp;[thread.timedmutex.requirements.general]'><span id='def:timed_mutex_types'><i >timed mutex types</i></span></a> are the standard library types <span class='texttt'>timed_<span class='shy'></span>mutex</span>,
<span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>, and <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span><a class='hidden_link' href='#thread.timedmutex.requirements.general-1.sentence-1'>.</a></div> <div id='thread.timedmutex.requirements.general-1.sentence-2' class='sentence'>They
meet the requirements set out below<a class='hidden_link' href='#thread.timedmutex.requirements.general-1.sentence-2'>.</a></div> <div id='thread.timedmutex.requirements.general-1.sentence-3' class='sentence'>In this description, <span class='texttt'>m</span> denotes an object of a mutex type,
<span class='texttt'>rel_<span class='shy'></span>time</span> denotes an object of an
instantiation of <a href='time.duration' title='30.5&emsp;Class template duration&emsp;[time.duration]'><span class='texttt'>duration</span></a>, and <span class='texttt'>abs_<span class='shy'></span>time</span> denotes an
object of an
instantiation of <a href='time.point' title='30.6&emsp;Class template time_&shy;point&emsp;[time.point]'><span class='texttt'>time_<span class='shy'></span>point</span></a><a class='hidden_link' href='#thread.timedmutex.requirements.general-1.sentence-3'>.</a></div> <div id='thread.timedmutex.requirements.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.timedmutex.requirements.general-note-1'>1</a></i>:&ensp;<div id='thread.timedmutex.requirements.general-1.sentence-4' class='sentence'>The timed mutex types meet the <a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a>
requirements (<a href='thread.req.lockable.timed' title='32.2.5.4&emsp;Cpp17TimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.timedmutex.requirements.general-1.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6874'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-2.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span> is well-formed
and has the following semantics:</div></div></div><div class='para' id='thread.timedmutex.requirements.general-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6878'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-3.sentence-1' class='sentence'><i >Preconditions</i>: If <span class='texttt'>m</span> is of type <span class='texttt'>timed_<span class='shy'></span>mutex</span> or
<span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>, the calling thread does not
own the mutex<a class='hidden_link' href='#thread.timedmutex.requirements.general-3.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6884'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-4.sentence-1' class='sentence'><i >Effects</i>: The function attempts to obtain ownership of the mutex within the
relative timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)
specified by <span class='texttt'>rel_<span class='shy'></span>time</span><a class='hidden_link' href='#thread.timedmutex.requirements.general-4.sentence-1'>.</a></div> <div id='thread.timedmutex.requirements.general-4.sentence-2' class='sentence'>If the time specified by <span class='texttt'>rel_<span class='shy'></span>time</span> is less than or
equal to <span class='texttt'>rel_<span class='shy'></span>time<span class='operator'>.</span>zero<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, the function attempts to obtain ownership without blocking (as if by calling
<span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>)<a class='hidden_link' href='#thread.timedmutex.requirements.general-4.sentence-2'>.</a></div> <div id='thread.timedmutex.requirements.general-4.sentence-3' class='sentence'>The function returns within the timeout specified by
<span class='texttt'>rel_<span class='shy'></span>time</span> only if it has obtained ownership of the mutex object<a class='hidden_link' href='#thread.timedmutex.requirements.general-4.sentence-3'>.</a></div> <div id='thread.timedmutex.requirements.general-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.timedmutex.requirements.general-note-2'>2</a></i>:&ensp;<div id='thread.timedmutex.requirements.general-4.sentence-4' class='sentence'>As
with <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, there is no guarantee that ownership will be obtained if the
lock is available, but implementations are expected to make a strong effort to do so<a class='hidden_link' href='#thread.timedmutex.requirements.general-4.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6898'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-5.sentence-1' class='sentence'><i >Synchronization</i>: If <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns <span class='texttt'><span class='literal'>true</span></span>, prior <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> operations
on the same object <a class='hidden_link' href='#def:synchronize_with' id='def:synchronize_with'><i>synchronize with</i></a> (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>) this operation<a class='hidden_link' href='#thread.timedmutex.requirements.general-5.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6903'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-6.sentence-1' class='sentence'><i >Return type</i>: <span class='texttt'><span class='keyword'>bool</span></span><a class='hidden_link' href='#thread.timedmutex.requirements.general-6.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6906'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-7.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='literal'>true</span></span> if ownership was obtained, otherwise <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.timedmutex.requirements.general-7.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6910'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-8.sentence-1' class='sentence'><i >Throws</i>: Timeout-related exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#thread.timedmutex.requirements.general-8.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-9'>9</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6915'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-9.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span> is well-formed
and has the following semantics:</div></div></div><div class='para' id='thread.timedmutex.requirements.general-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6919'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-10.sentence-1' class='sentence'><i >Preconditions</i>: If <span class='texttt'>m</span> is of type <span class='texttt'>timed_<span class='shy'></span>mutex</span> or
<span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>, the calling thread does not own the
mutex<a class='hidden_link' href='#thread.timedmutex.requirements.general-10.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6925'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-11.sentence-1' class='sentence'><i >Effects</i>: The function attempts to obtain ownership of the mutex<a class='hidden_link' href='#thread.timedmutex.requirements.general-11.sentence-1'>.</a></div> <div id='thread.timedmutex.requirements.general-11.sentence-2' class='sentence'>If
<span class='texttt'>abs_<span class='shy'></span>time</span> has already passed, the function attempts to obtain ownership
without blocking (as if by calling <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>)<a class='hidden_link' href='#thread.timedmutex.requirements.general-11.sentence-2'>.</a></div> <div id='thread.timedmutex.requirements.general-11.sentence-3' class='sentence'>The function
returns before the absolute timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by
<span class='texttt'>abs_<span class='shy'></span>time</span> only if it has obtained ownership of the mutex object<a class='hidden_link' href='#thread.timedmutex.requirements.general-11.sentence-3'>.</a></div> <div id='thread.timedmutex.requirements.general-note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.timedmutex.requirements.general-note-3'>3</a></i>:&ensp;<div id='thread.timedmutex.requirements.general-11.sentence-4' class='sentence'>As with <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, there is no guarantee that ownership will
be obtained if the lock is available, but implementations are expected to make a
strong effort to do so<a class='hidden_link' href='#thread.timedmutex.requirements.general-11.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6938'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-12.sentence-1' class='sentence'><i >Synchronization</i>: If <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns <span class='texttt'><span class='literal'>true</span></span>, prior <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
operations on the same object <a class='hidden_link' href='#def:synchronize_with' id='def:synchronize_with'><i>synchronize with</i></a> (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>)
this operation<a class='hidden_link' href='#thread.timedmutex.requirements.general-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6944'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-13.sentence-1' class='sentence'><i >Return type</i>: <span class='texttt'><span class='keyword'>bool</span></span><a class='hidden_link' href='#thread.timedmutex.requirements.general-13.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6947'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-14.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='literal'>true</span></span> if ownership was obtained, otherwise <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.timedmutex.requirements.general-14.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.timedmutex.requirements.general-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.requirements.general-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6951'>#</a></div><div class='texpara'><div id='thread.timedmutex.requirements.general-15.sentence-1' class='sentence'><i >Throws</i>: Timeout-related exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#thread.timedmutex.requirements.general-15.sentence-1'>.</a></div></div></div></div></div><div id='thread.timedmutex.class' class='section'><h4 ><a class='secnum' href='#thread.timedmutex.class' style='min-width:110pt'>32.6.4.3.2</a> Class <span class='texttt'>timed_<span class='shy'></span>mutex</span> <a class='abbr_ref' href='thread.timedmutex.class'>[thread.timedmutex.class]</a></h4><div class='texpara'><span id='lib:timed_mutex'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:timed_mutex'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> timed_mutex <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class="added">constexpr </span>timed_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>timed_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    timed_mutex<span class='parenthesis'>(</span><span class='keyword'>const</span> timed_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    timed_mutex<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> timed_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;    <span class='comment'>// blocking</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='keyword'>using</span> native_handle_type <span class='operator'>=</span> <i >implementation-defined</i>;          <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
    native_handle_type native_handle<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                         <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.timedmutex.class-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.class-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6983'>#</a></div><div class='texpara'><div id='thread.timedmutex.class-1.sentence-1' class='sentence'><a class='index' id=':block_(execution)___'></a>The class <span class='texttt'>timed_<span class='shy'></span>mutex</span> provides a non-recursive mutex with exclusive ownership
semantics<a class='hidden_link' href='#thread.timedmutex.class-1.sentence-1'>.</a></div> <div id='thread.timedmutex.class-1.sentence-2' class='sentence'>If one thread owns a <span class='texttt'>timed_<span class='shy'></span>mutex</span> object, attempts by another thread
to acquire ownership of that object will fail (for <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) or block
(for <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, and <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) until
the owning thread has released ownership with a call to <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> or the
call to <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> or <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> times out (having
failed to obtain ownership)<a class='hidden_link' href='#thread.timedmutex.class-1.sentence-2'>.</a></div></div></div><div class='para' id='thread.timedmutex.class-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.class-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6993'>#</a></div><div class='texpara'><div id='thread.timedmutex.class-2.sentence-1' class='sentence'>The class <span class='texttt'>timed_<span class='shy'></span>mutex</span> meets
all of the timed mutex requirements (<a href='#thread.timedmutex.requirements' title='32.6.4.3&emsp;Timed mutex types'>[thread.<span class='shy'></span>timedmutex.<span class='shy'></span>requirements]</a>)<a class='hidden_link' href='#thread.timedmutex.class-2.sentence-1'>.</a></div> <div id='thread.timedmutex.class-2.sentence-2' class='sentence'>It is a standard-layout class (<a href='class.prop' title='11.2&emsp;Properties of classes'>[class.<span class='shy'></span>prop]</a>)<a class='hidden_link' href='#thread.timedmutex.class-2.sentence-2'>.</a></div></div></div><div class='para' id='thread.timedmutex.class-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.class-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L6998'>#</a></div><div class='texpara'><div id='thread.timedmutex.class-3.sentence-1' class='sentence'>The behavior of a program is undefined if
<ul class='itemize'><li id='thread.timedmutex.class-3.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.timedmutex.class-3.1'>(3.1)</a></div>it destroys a <span class='texttt'>timed_<span class='shy'></span>mutex</span> object owned by any thread,</li><li id='thread.timedmutex.class-3.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.timedmutex.class-3.2'>(3.2)</a></div>a thread that owns a <span class='texttt'>timed_<span class='shy'></span>mutex</span> object calls <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
<span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, or <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> on that object, or</li><li id='thread.timedmutex.class-3.3'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.timedmutex.class-3.3'>(3.3)</a></div>a thread terminates while owning a <span class='texttt'>timed_<span class='shy'></span>mutex</span> object<a class='hidden_link' href='#thread.timedmutex.class-3.sentence-1'>.</a></li></ul></div></div></div></div><div id='thread.timedmutex.recursive' class='section'><h4 ><a class='secnum' href='#thread.timedmutex.recursive' style='min-width:110pt'>32.6.4.3.3</a> Class <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> <a class='abbr_ref' href='thread.timedmutex.recursive'>[thread.timedmutex.recursive]</a></h4><div class='texpara'><span id='lib:recursive_timed_mutex'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:recursive_timed_mutex'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> recursive_timed_mutex <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class="added">constexpr </span>recursive_timed_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>recursive_timed_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    recursive_timed_mutex<span class='parenthesis'>(</span><span class='keyword'>const</span> recursive_timed_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    recursive_timed_mutex<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> recursive_timed_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;    <span class='comment'>// blocking</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='keyword'>using</span> native_handle_type <span class='operator'>=</span> <i >implementation-defined</i>;          <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
    native_handle_type native_handle<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                         <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.timedmutex.recursive-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.recursive-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7034'>#</a></div><div class='texpara'><div id='thread.timedmutex.recursive-1.sentence-1' class='sentence'><a class='index' id=':block_(execution)____'></a>The class <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> provides a recursive mutex with exclusive
ownership semantics<a class='hidden_link' href='#thread.timedmutex.recursive-1.sentence-1'>.</a></div> <div id='thread.timedmutex.recursive-1.sentence-2' class='sentence'>If one thread owns a <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> object,
attempts by another thread to acquire ownership of that object will fail (for
<span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) or block (for <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, and
<span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>) until the owning thread has completely released
ownership or the call to <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> or <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
times out (having failed to obtain ownership)<a class='hidden_link' href='#thread.timedmutex.recursive-1.sentence-2'>.</a></div></div></div><div class='para' id='thread.timedmutex.recursive-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.recursive-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7044'>#</a></div><div class='texpara'><div id='thread.timedmutex.recursive-2.sentence-1' class='sentence'>The class <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> meets
all of the timed mutex requirements (<a href='#thread.timedmutex.requirements' title='32.6.4.3&emsp;Timed mutex types'>[thread.<span class='shy'></span>timedmutex.<span class='shy'></span>requirements]</a>)<a class='hidden_link' href='#thread.timedmutex.recursive-2.sentence-1'>.</a></div> <div id='thread.timedmutex.recursive-2.sentence-2' class='sentence'>It is a standard-layout class (<a href='class.prop' title='11.2&emsp;Properties of classes'>[class.<span class='shy'></span>prop]</a>)<a class='hidden_link' href='#thread.timedmutex.recursive-2.sentence-2'>.</a></div></div></div><div class='para' id='thread.timedmutex.recursive-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.recursive-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7049'>#</a></div><div class='texpara'><div id='thread.timedmutex.recursive-3.sentence-1' class='sentence'>A thread that owns a <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> object may acquire additional
levels of ownership by calling <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
<span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, or <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> on that object<a class='hidden_link' href='#thread.timedmutex.recursive-3.sentence-1'>.</a></div> <div id='thread.timedmutex.recursive-3.sentence-2' class='sentence'>It is
unspecified how many levels of ownership may be acquired by a single thread<a class='hidden_link' href='#thread.timedmutex.recursive-3.sentence-2'>.</a></div> <div id='thread.timedmutex.recursive-3.sentence-3' class='sentence'>If
a thread has already acquired the maximum level of ownership for a
<span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> object, additional calls to <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
<span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, or <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> fail, and additional
calls to <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> throw an exception of type <span class='texttt'>system_<span class='shy'></span>error</span><a class='hidden_link' href='#thread.timedmutex.recursive-3.sentence-3'>.</a></div> <div id='thread.timedmutex.recursive-3.sentence-4' class='sentence'>A
thread shall call <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> once for each level of ownership acquired by
calls to <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, and
<span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.timedmutex.recursive-3.sentence-4'>.</a></div> <div id='thread.timedmutex.recursive-3.sentence-5' class='sentence'>Only when all levels of ownership have been released
may ownership of the object be acquired by another thread<a class='hidden_link' href='#thread.timedmutex.recursive-3.sentence-5'>.</a></div></div></div><div class='para' id='thread.timedmutex.recursive-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.timedmutex.recursive-4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7063'>#</a></div><div class='texpara'><div id='thread.timedmutex.recursive-4.sentence-1' class='sentence'>The behavior of a program is undefined if
<ul class='itemize'><li id='thread.timedmutex.recursive-4.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.timedmutex.recursive-4.1'>(4.1)</a></div>it destroys a <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> object owned by any thread, or</li><li id='thread.timedmutex.recursive-4.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.timedmutex.recursive-4.2'>(4.2)</a></div>a thread terminates while owning a <span class='texttt'>recursive_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> object<a class='hidden_link' href='#thread.timedmutex.recursive-4.sentence-1'>.</a></li></ul></div></div></div></div></div><div id='thread.sharedmutex.requirements' class='section'><h4 ><a class='secnum' href='#thread.sharedmutex.requirements' style='min-width:95pt'>32.6.4.4</a> Shared mutex types <a class='abbr_ref' href='thread.sharedmutex.requirements'>[thread.sharedmutex.requirements]</a></h4><div id='thread.sharedmutex.requirements.general' class='section'><h4 ><a class='secnum' href='#thread.sharedmutex.requirements.general' style='min-width:110pt'>32.6.4.4.1</a> General <a class='abbr_ref' href='thread.sharedmutex.requirements.general'>[thread.sharedmutex.requirements.general]</a></h4><div class='para' id='thread.sharedmutex.requirements.general-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7075'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-1.sentence-1' class='sentence'>The standard library types <span class='texttt'>shared_<span class='shy'></span>mutex</span> and <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>
are <a class='hidden_link' href='#def:shared_mutex_types' title='32.6.4.4.1&emsp;General&emsp;[thread.sharedmutex.requirements.general]'><span id='def:shared_mutex_types'><i >shared mutex types</i></span></a><a class='hidden_link' href='#thread.sharedmutex.requirements.general-1.sentence-1'>.</a></div> <div id='thread.sharedmutex.requirements.general-1.sentence-2' class='sentence'>Shared mutex types meet the requirements of
mutex types (<a href='#requirements.mutex' title='32.6.4.2&emsp;Mutex types'>[thread.<span class='shy'></span>mutex.<span class='shy'></span>requirements.<span class='shy'></span>mutex]</a>) and additionally
meet the requirements set out below<a class='hidden_link' href='#thread.sharedmutex.requirements.general-1.sentence-2'>.</a></div> <div id='thread.sharedmutex.requirements.general-1.sentence-3' class='sentence'>In this description,
<span class='texttt'>m</span> denotes an object of a shared mutex type<a class='hidden_link' href='#thread.sharedmutex.requirements.general-1.sentence-3'>.</a></div> <div id='thread.sharedmutex.requirements.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.sharedmutex.requirements.general-note-1'>1</a></i>:&ensp;<div id='thread.sharedmutex.requirements.general-1.sentence-4' class='sentence'>The shared mutex types meet the <a href='thread.req.lockable.shared#:Cpp17SharedLockable' title='32.2.5.5&emsp;Cpp17SharedLockable requirements&emsp;[thread.req.lockable.shared]'><i >Cpp17SharedLockable</i></a>
requirements (<a href='thread.req.lockable.shared' title='32.2.5.5&emsp;Cpp17SharedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared]</a>)<a class='hidden_link' href='#thread.sharedmutex.requirements.general-1.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7086'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-2.sentence-1' class='sentence'><a class='index' id=':block_(execution)_____'></a>In addition to the exclusive lock ownership mode specified
in <a href='#requirements.mutex' title='32.6.4.2&emsp;Mutex types'>[thread.<span class='shy'></span>mutex.<span class='shy'></span>requirements.<span class='shy'></span>mutex]</a>, shared mutex types provide a
<a class='hidden_link' href='#def:shared_lock' title='32.6.4.4.1&emsp;General&emsp;[thread.sharedmutex.requirements.general]'><span id='def:shared_lock'><i >shared lock</i></span></a> ownership mode<a class='hidden_link' href='#thread.sharedmutex.requirements.general-2.sentence-1'>.</a></div> <div id='thread.sharedmutex.requirements.general-2.sentence-2' class='sentence'>Multiple execution agents can
simultaneously hold a shared lock ownership of a shared mutex type<a class='hidden_link' href='#thread.sharedmutex.requirements.general-2.sentence-2'>.</a></div> <div id='thread.sharedmutex.requirements.general-2.sentence-3' class='sentence'>But no
execution agent holds a shared lock while another execution agent holds an
exclusive lock on the same shared mutex type, and vice-versa<a class='hidden_link' href='#thread.sharedmutex.requirements.general-2.sentence-3'>.</a></div> <div id='thread.sharedmutex.requirements.general-2.sentence-4' class='sentence'>The maximum
number of execution agents which can share a shared lock on a single shared
mutex type is unspecified, but is at least 10000<a class='hidden_link' href='#thread.sharedmutex.requirements.general-2.sentence-4'>.</a></div> <div id='thread.sharedmutex.requirements.general-2.sentence-5' class='sentence'>If more than the
maximum number of execution agents attempt to obtain a shared lock, the
excess execution agents block until the number of shared locks are
reduced below the maximum amount by other execution agents releasing their
shared lock<a class='hidden_link' href='#thread.sharedmutex.requirements.general-2.sentence-5'>.</a></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7101'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-3.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is well-formed and has the
following semantics:</div></div></div><div class='para' id='thread.sharedmutex.requirements.general-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7105'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-4.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread has no ownership of the mutex<a class='hidden_link' href='#thread.sharedmutex.requirements.general-4.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7109'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-5.sentence-1' class='sentence'><a class='index' id=':block_(execution)______'></a><i >Effects</i>: Blocks the calling thread until shared ownership of the mutex can be obtained for the calling thread<a class='hidden_link' href='#thread.sharedmutex.requirements.general-5.sentence-1'>.</a></div> <div id='thread.sharedmutex.requirements.general-5.sentence-2' class='sentence'>If an exception is thrown then a shared lock has not been acquired for the current thread<a class='hidden_link' href='#thread.sharedmutex.requirements.general-5.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7115'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-6.sentence-1' class='sentence'><i >Synchronization</i>: Prior <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> operations on the same object synchronize with (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>) this operation<a class='hidden_link' href='#thread.sharedmutex.requirements.general-6.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7119'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-7.sentence-1' class='sentence'><i >Postconditions</i>: The calling thread has a shared lock on the mutex<a class='hidden_link' href='#thread.sharedmutex.requirements.general-7.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7123'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-8.sentence-1' class='sentence'><i >Return type</i>: <span id=':void__'><span class='texttt'><span class='keyword'>void</span></span></span><a class='hidden_link' href='#thread.sharedmutex.requirements.general-8.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7126'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-9.sentence-1' class='sentence'><i >Throws</i>: <span class='texttt'>system_<span class='shy'></span>error</span> when an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.sharedmutex.requirements.general-9.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7130'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-10.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.sharedmutex.requirements.general-10.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.sharedmutex.requirements.general-10.1'>(10.1)</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-10.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if the thread does not have the privilege to perform the operation<a class='hidden_link' href='#thread.sharedmutex.requirements.general-10.1.sentence-1'>.</a></div></div></li><li id='thread.sharedmutex.requirements.general-10.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.sharedmutex.requirements.general-10.2'>(10.2)</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-10.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if the implementation detects that a deadlock would occur<a class='hidden_link' href='#thread.sharedmutex.requirements.general-10.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-11'>11</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7138'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-11.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>unlock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is well-formed and has the following semantics:</div></div></div><div class='para' id='thread.sharedmutex.requirements.general-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7141'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-12.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread holds a shared lock on the mutex<a class='hidden_link' href='#thread.sharedmutex.requirements.general-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7145'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-13.sentence-1' class='sentence'><i >Effects</i>: Releases a shared lock on the mutex held by the calling thread<a class='hidden_link' href='#thread.sharedmutex.requirements.general-13.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7149'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-14.sentence-1' class='sentence'><i >Return type</i>: <span id=':void___'><span class='texttt'><span class='keyword'>void</span></span></span><a class='hidden_link' href='#thread.sharedmutex.requirements.general-14.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7152'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-15.sentence-1' class='sentence'><i >Synchronization</i>: This operation <a href='intro.multithread#def:synchronize_with' title='6.9.2&emsp;Multi-threaded executions and data races&emsp;[intro.multithread]'>synchronizes with</a> subsequent
<span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> operations that obtain ownership on the same object<a class='hidden_link' href='#thread.sharedmutex.requirements.general-15.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-16'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7157'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-16.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#thread.sharedmutex.requirements.general-16.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-17'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-17'>17</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7162'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-17.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is well-formed and has the following semantics:</div></div></div><div class='para' id='thread.sharedmutex.requirements.general-18'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7165'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-18.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread has no ownership of the mutex<a class='hidden_link' href='#thread.sharedmutex.requirements.general-18.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-19'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-19'>19</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7169'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-19.sentence-1' class='sentence'><i >Effects</i>: Attempts to obtain shared ownership of the mutex for the calling
thread without blocking<a class='hidden_link' href='#thread.sharedmutex.requirements.general-19.sentence-1'>.</a></div> <div id='thread.sharedmutex.requirements.general-19.sentence-2' class='sentence'>If shared ownership is not obtained, there is no
effect and <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> immediately returns<a class='hidden_link' href='#thread.sharedmutex.requirements.general-19.sentence-2'>.</a></div> <div id='thread.sharedmutex.requirements.general-19.sentence-3' class='sentence'>An implementation
may fail to obtain the lock even if it is not held by any other thread<a class='hidden_link' href='#thread.sharedmutex.requirements.general-19.sentence-3'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-20'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-20'>20</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7176'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-20.sentence-1' class='sentence'><i >Synchronization</i>: If <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns <span class='texttt'><span class='literal'>true</span></span>, prior <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
operations on the same object synchronize with (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>) this
operation<a class='hidden_link' href='#thread.sharedmutex.requirements.general-20.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-21'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-21'>21</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7182'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-21.sentence-1' class='sentence'><i >Return type</i>: <span class='texttt'><span class='keyword'>bool</span></span><a class='hidden_link' href='#thread.sharedmutex.requirements.general-21.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-22'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-22'>22</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7185'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-22.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='literal'>true</span></span> if the shared lock was acquired, otherwise <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.sharedmutex.requirements.general-22.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedmutex.requirements.general-23'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.requirements.general-23'>23</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7189'>#</a></div><div class='texpara'><div id='thread.sharedmutex.requirements.general-23.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#thread.sharedmutex.requirements.general-23.sentence-1'>.</a></div></div></div></div></div><div id='thread.sharedmutex.class' class='section'><h4 ><a class='secnum' href='#thread.sharedmutex.class' style='min-width:110pt'>32.6.4.4.2</a> Class <span class='texttt'>shared_<span class='shy'></span>mutex</span> <a class='abbr_ref' href='thread.sharedmutex.class'>[thread.sharedmutex.class]</a></h4><div class='texpara'><span id='lib:shared_mutex'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_mutex'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> shared_mutex <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class="added">constexpr </span>shared_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>shared_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    shared_mutex<span class='parenthesis'>(</span><span class='keyword'>const</span> shared_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    shared_mutex<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> shared_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class='comment'>// exclusive ownership</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                <span class='comment'>// blocking</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='comment'>// shared ownership</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> lock_shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;         <span class='comment'>// blocking</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock_shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='keyword'>using</span> native_handle_type <span class='operator'>=</span> <i >implementation-defined</i>;          <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
    native_handle_type native_handle<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                         <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.sharedmutex.class-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.class-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7223'>#</a></div><div class='texpara'><div id='thread.sharedmutex.class-1.sentence-1' class='sentence'>The class <span class='texttt'>shared_<span class='shy'></span>mutex</span> provides a non-recursive mutex
with shared ownership semantics<a class='hidden_link' href='#thread.sharedmutex.class-1.sentence-1'>.</a></div></div></div><div class='para' id='thread.sharedmutex.class-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.class-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7227'>#</a></div><div class='texpara'><div id='thread.sharedmutex.class-2.sentence-1' class='sentence'>The class <span class='texttt'>shared_<span class='shy'></span>mutex</span> meets
all of the shared mutex requirements (<a href='#thread.sharedmutex.requirements' title='32.6.4.4&emsp;Shared mutex types'>[thread.<span class='shy'></span>sharedmutex.<span class='shy'></span>requirements]</a>)<a class='hidden_link' href='#thread.sharedmutex.class-2.sentence-1'>.</a></div> <div id='thread.sharedmutex.class-2.sentence-2' class='sentence'>It is a standard-layout class (<a href='class.prop' title='11.2&emsp;Properties of classes'>[class.<span class='shy'></span>prop]</a>)<a class='hidden_link' href='#thread.sharedmutex.class-2.sentence-2'>.</a></div></div></div><div class='para' id='thread.sharedmutex.class-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.class-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7232'>#</a></div><div class='texpara'><div id='thread.sharedmutex.class-3.sentence-1' class='sentence'>The behavior of a program is undefined if
<ul class='itemize'><li id='thread.sharedmutex.class-3.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.sharedmutex.class-3.1'>(3.1)</a></div>it destroys a <span class='texttt'>shared_<span class='shy'></span>mutex</span> object owned by any thread,</li><li id='thread.sharedmutex.class-3.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.sharedmutex.class-3.2'>(3.2)</a></div>a thread attempts to recursively gain any ownership of a <span class='texttt'>shared_<span class='shy'></span>mutex</span>, or</li><li id='thread.sharedmutex.class-3.3'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.sharedmutex.class-3.3'>(3.3)</a></div>a thread terminates while possessing any ownership of a <span class='texttt'>shared_<span class='shy'></span>mutex</span><a class='hidden_link' href='#thread.sharedmutex.class-3.sentence-1'>.</a></li></ul></div></div></div><div class='para' id='thread.sharedmutex.class-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedmutex.class-4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7240'>#</a></div><div class='texpara'><div id='thread.sharedmutex.class-4.sentence-1' class='sentence'><span class='texttt'>shared_<span class='shy'></span>mutex</span> may be a synonym for <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span><a class='hidden_link' href='#thread.sharedmutex.class-4.sentence-1'>.</a></div></div></div></div></div><div id='thread.sharedtimedmutex.requirements' class='section'><h4 ><a class='secnum' href='#thread.sharedtimedmutex.requirements' style='min-width:95pt'>32.6.4.5</a> Shared timed mutex types <a class='abbr_ref' href='thread.sharedtimedmutex.requirements'>[thread.sharedtimedmutex.requirements]</a></h4><div id='thread.sharedtimedmutex.requirements.general' class='section'><h4 ><a class='secnum' href='#thread.sharedtimedmutex.requirements.general' style='min-width:110pt'>32.6.4.5.1</a> General <a class='abbr_ref' href='thread.sharedtimedmutex.requirements.general'>[thread.sharedtimedmutex.requirements.general]</a></h4><div class='para' id='thread.sharedtimedmutex.requirements.general-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7247'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-1.sentence-1' class='sentence'>The standard library type <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> is a
<a class='hidden_link' href='#def:shared_timed_mutex_type' title='32.6.4.5.1&emsp;General&emsp;[thread.sharedtimedmutex.requirements.general]'><span id='def:shared_timed_mutex_type'><i >shared timed mutex type</i></span></a><a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-1.sentence-1'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-1.sentence-2' class='sentence'>Shared timed mutex types meet the requirements of
timed mutex types (<a href='#thread.timedmutex.requirements' title='32.6.4.3&emsp;Timed mutex types'>[thread.<span class='shy'></span>timedmutex.<span class='shy'></span>requirements]</a>),
shared mutex types (<a href='#thread.sharedmutex.requirements' title='32.6.4.4&emsp;Shared mutex types'>[thread.<span class='shy'></span>sharedmutex.<span class='shy'></span>requirements]</a>), and additionally
meet the requirements set out below<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-1.sentence-2'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-1.sentence-3' class='sentence'>In this description,
<span class='texttt'>m</span> denotes an object of a shared timed mutex type,
<span class='texttt'>rel_<span class='shy'></span>time</span> denotes an object of an instantiation of
<span class='texttt'>duration</span> (<a href='time.duration' title='30.5&emsp;Class template duration'>[time.<span class='shy'></span>duration]</a>), and
<span class='texttt'>abs_<span class='shy'></span>time</span> denotes an object of an instantiation of
<a href='time.point' title='30.6&emsp;Class template time_&shy;point&emsp;[time.point]'><span class='texttt'>time_<span class='shy'></span>point</span></a><a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-1.sentence-3'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.sharedtimedmutex.requirements.general-note-1'>1</a></i>:&ensp;<div id='thread.sharedtimedmutex.requirements.general-1.sentence-4' class='sentence'>The shared timed mutex types meet the <a href='thread.req.lockable.shared.timed#:Cpp17SharedTimedLockable' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements&emsp;[thread.req.lockable.shared.timed]'><i >Cpp17SharedTimedLockable</i></a>
requirements (<a href='thread.req.lockable.shared.timed' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-1.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7263'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-2.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span> is well-formed and
has the following semantics:</div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7267'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-3.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread has no ownership of the mutex<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-3.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7271'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-4.sentence-1' class='sentence'><i >Effects</i>: Attempts to obtain
shared lock ownership for the calling thread within the relative
timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by <span class='texttt'>rel_<span class='shy'></span>time</span><a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-4.sentence-1'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-4.sentence-2' class='sentence'>If the time
specified by <span class='texttt'>rel_<span class='shy'></span>time</span> is less than or equal to <span class='texttt'>rel_<span class='shy'></span>time<span class='operator'>.</span>zero<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
the function attempts to obtain ownership without blocking (as if by calling
<span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>)<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-4.sentence-2'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-4.sentence-3' class='sentence'>The function returns within the timeout
specified by <span class='texttt'>rel_<span class='shy'></span>time</span> only if it has obtained shared ownership of the
mutex object<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-4.sentence-3'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.sharedtimedmutex.requirements.general-note-2'>2</a></i>:&ensp;<div id='thread.sharedtimedmutex.requirements.general-4.sentence-4' class='sentence'>As with <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, there is no guarantee that
ownership will be obtained if the lock is available, but implementations are
expected to make a strong effort to do so<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-4.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div> <div id='thread.sharedtimedmutex.requirements.general-4.sentence-5' class='sentence'>
If an exception is thrown then a shared lock has not been acquired for
the current thread<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-4.sentence-5'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7289'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-5.sentence-1' class='sentence'><i >Synchronization</i>: If <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns <span class='texttt'><span class='literal'>true</span></span>, prior
<span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> operations on the same object synchronize
with (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>) this operation<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-5.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7295'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-6.sentence-1' class='sentence'><i >Return type</i>: <span class='texttt'><span class='keyword'>bool</span></span><a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-6.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7298'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-7.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='literal'>true</span></span> if the shared lock was acquired, otherwise <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-7.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7302'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-8.sentence-1' class='sentence'><i >Throws</i>: Timeout-related exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-8.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-9'>9</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7307'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-9.sentence-1' class='sentence'>The expression <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span> is well-formed
and has the following semantics:</div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7311'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-10.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread has no ownership of the mutex<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-10.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7315'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-11.sentence-1' class='sentence'><i >Effects</i>: The function attempts to obtain shared ownership of the mutex<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-11.sentence-1'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-11.sentence-2' class='sentence'>If
<span class='texttt'>abs_<span class='shy'></span>time</span> has already passed, the function attempts to obtain shared
ownership without blocking (as if by calling <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>)<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-11.sentence-2'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-11.sentence-3' class='sentence'>The
function returns before the absolute timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)
specified by <span class='texttt'>abs_<span class='shy'></span>time</span> only if it has obtained shared ownership of the
mutex object<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-11.sentence-3'>.</a></div> <div id='thread.sharedtimedmutex.requirements.general-note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.sharedtimedmutex.requirements.general-note-3'>3</a></i>:&ensp;<div id='thread.sharedtimedmutex.requirements.general-11.sentence-4' class='sentence'>As with <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, there is no guarantee that
ownership will be obtained if the lock is available, but implementations are
expected to make a strong effort to do so<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-11.sentence-4'>.</a></div> —&nbsp;<i>end note</i>]</div></div> <div id='thread.sharedtimedmutex.requirements.general-11.sentence-5' class='sentence'>
If an exception is thrown then a shared lock has not been acquired for
the current thread<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-11.sentence-5'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7331'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-12.sentence-1' class='sentence'><i >Synchronization</i>: If <span class='texttt'>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns <span class='texttt'><span class='literal'>true</span></span>, prior
<span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> operations on the same object synchronize
with (<a href='intro.multithread' title='6.9.2&emsp;Multi-threaded executions and data races'>[intro.<span class='shy'></span>multithread]</a>) this operation<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7337'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-13.sentence-1' class='sentence'><i >Return type</i>: <span class='texttt'><span class='keyword'>bool</span></span><a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-13.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7340'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-14.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='literal'>true</span></span> if the shared lock was acquired, otherwise <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-14.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.sharedtimedmutex.requirements.general-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.requirements.general-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7344'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.requirements.general-15.sentence-1' class='sentence'><i >Throws</i>: Timeout-related exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#thread.sharedtimedmutex.requirements.general-15.sentence-1'>.</a></div></div></div></div></div><div id='thread.sharedtimedmutex.class' class='section'><h4 ><a class='secnum' href='#thread.sharedtimedmutex.class' style='min-width:110pt'>32.6.4.5.2</a> Class <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> <a class='abbr_ref' href='thread.sharedtimedmutex.class'>[thread.sharedtimedmutex.class]</a></h4><div class='texpara'><span id='lib:shared_timed_mutex'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_timed_mutex'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> shared_timed_mutex <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class="added">constexpr </span>shared_timed_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>shared_timed_mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    shared_timed_mutex<span class='parenthesis'>(</span><span class='keyword'>const</span> shared_timed_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    shared_timed_mutex<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> shared_timed_mutex<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class='comment'>// exclusive ownership</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                <span class='comment'>// blocking</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='comment'>// shared ownership</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> lock_shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;         <span class='comment'>// blocking</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_shared_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_shared_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock_shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.sharedtimedmutex.class-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.class-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7383'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.class-1.sentence-1' class='sentence'>The class <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> provides a non-recursive mutex with shared
ownership semantics<a class='hidden_link' href='#thread.sharedtimedmutex.class-1.sentence-1'>.</a></div></div></div><div class='para' id='thread.sharedtimedmutex.class-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.class-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7387'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.class-2.sentence-1' class='sentence'>The class <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> meets
all of the shared timed mutex requirements (<a href='#thread.sharedtimedmutex.requirements' title='32.6.4.5&emsp;Shared timed mutex types'>[thread.<span class='shy'></span>sharedtimedmutex.<span class='shy'></span>requirements]</a>)<a class='hidden_link' href='#thread.sharedtimedmutex.class-2.sentence-1'>.</a></div> <div id='thread.sharedtimedmutex.class-2.sentence-2' class='sentence'>It is a standard-layout class (<a href='class.prop' title='11.2&emsp;Properties of classes'>[class.<span class='shy'></span>prop]</a>)<a class='hidden_link' href='#thread.sharedtimedmutex.class-2.sentence-2'>.</a></div></div></div><div class='para' id='thread.sharedtimedmutex.class-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.sharedtimedmutex.class-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7392'>#</a></div><div class='texpara'><div id='thread.sharedtimedmutex.class-3.sentence-1' class='sentence'>The behavior of a program is undefined if
<ul class='itemize'><li id='thread.sharedtimedmutex.class-3.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.sharedtimedmutex.class-3.1'>(3.1)</a></div>it destroys a <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span> object owned by any thread,</li><li id='thread.sharedtimedmutex.class-3.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.sharedtimedmutex.class-3.2'>(3.2)</a></div>a thread attempts to recursively gain any ownership of a <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span>, or</li><li id='thread.sharedtimedmutex.class-3.3'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.sharedtimedmutex.class-3.3'>(3.3)</a></div>a thread terminates while possessing any ownership of a <span class='texttt'>shared_<span class='shy'></span>timed_<span class='shy'></span>mutex</span><a class='hidden_link' href='#thread.sharedtimedmutex.class-3.sentence-1'>.</a></li></ul></div></div></div></div></div></div><div id='thread.lock' class='section'><h3 ><a class='secnum' href='#thread.lock' style='min-width:80pt'>32.6.5</a> Locks <a class='abbr_ref' href='thread.lock'>[thread.lock]</a></h3><div id='thread.lock.general' class='section'><h4 ><a class='secnum' href='#thread.lock.general' style='min-width:95pt'>32.6.5.1</a> General <a class='abbr_ref' href='thread.lock.general'>[thread.lock.general]</a></h4><div class='para' id='thread.lock.general-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7404'>#</a></div><div class='texpara'><div id='thread.lock.general-1.sentence-1' class='sentence'>A <a class='hidden_link' href='#def:lock' id='def:lock'><i>lock</i></a> is an object that holds a reference to a lockable object and may unlock the
lockable object during the lock's destruction (such as when leaving block scope)<a class='hidden_link' href='#thread.lock.general-1.sentence-1'>.</a></div> <div id='thread.lock.general-1.sentence-2' class='sentence'>An execution
agent may use a lock to aid in managing ownership of a lockable object in an exception safe
manner<a class='hidden_link' href='#thread.lock.general-1.sentence-2'>.</a></div> <div id='thread.lock.general-1.sentence-3' class='sentence'>A lock is said to <a class='hidden_link' href='#def:own' id='def:own'><i>own</i></a> a lockable object if it is currently managing the
ownership of that lockable object for an execution agent<a class='hidden_link' href='#thread.lock.general-1.sentence-3'>.</a></div> <div id='thread.lock.general-1.sentence-4' class='sentence'>A lock does not manage the lifetime
of the lockable object it references<a class='hidden_link' href='#thread.lock.general-1.sentence-4'>.</a></div> <div id='thread.lock.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.lock.general-note-1'>1</a></i>:&ensp;<div id='thread.lock.general-1.sentence-5' class='sentence'>Locks are intended to ease the burden of
unlocking the lockable object under both normal and exceptional circumstances<a class='hidden_link' href='#thread.lock.general-1.sentence-5'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='para' id='thread.lock.general-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7416'>#</a></div><div class='texpara'><div id='thread.lock.general-2.sentence-1' class='sentence'>Some lock constructors take tag types which describe what should be done with the lockable
object during the lock's construction<a class='hidden_link' href='#thread.lock.general-2.sentence-1'>.</a></div></div><div class='texpara'><span id='lib:adopt_lock'><span id='lib:try_to_lock'><span id='lib:defer_lock'><span id='lib:adopt_lock_t'><span id='lib:try_to_lock_t'><span id='lib:defer_lock_t'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:defer_lock_t'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>struct</span> defer_lock_t  <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;     <span class='comment'>// do not acquire ownership of the mutex</span>
  <span class='keyword'>struct</span> try_to_lock_t <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;     <span class='comment'>// try to acquire ownership of the mutex</span>
                                <span class='comment'>// without blocking</span>
  <span class='keyword'>struct</span> adopt_lock_t  <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;     <span class='comment'>// assume the calling thread has already</span>
                                <span class='comment'>// obtained mutex ownership and manage it</span>

  <span class='keyword'>inline</span> <span class='keyword'>constexpr</span> defer_lock_t   defer_lock <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;
  <span class='keyword'>inline</span> <span class='keyword'>constexpr</span> try_to_lock_t  try_to_lock <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;
  <span class='keyword'>inline</span> <span class='keyword'>constexpr</span> adopt_lock_t   adopt_lock <span class='curlybracket'>{</span> <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></span></span></span></span></span></div></div></div><div id='thread.lock.guard' class='section'><h4 ><a class='secnum' href='#thread.lock.guard' style='min-width:95pt'>32.6.5.2</a> Class template <span class='texttt'>lock_<span class='shy'></span>guard</span> <a class='abbr_ref' href='thread.lock.guard'>[thread.lock.guard]</a></h4><div class='texpara'><span id='lib:lock_guard'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:lock_guard'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span>
  <span class='keyword'>class</span> lock_guard <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class='keyword'>using</span> mutex_type <span class='operator'>=</span> Mutex;

    <span class="added">constexpr </span><span class='keyword'>explicit</span> lock_guard<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span>lock_guard<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, adopt_lock_t<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>lock_guard<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    lock_guard<span class='parenthesis'>(</span><span class='keyword'>const</span> lock_guard<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    lock_guard<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> lock_guard<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

  <span class='keyword'>private</span><span class='operator'>:</span>
    mutex_type<span class='operator'>&amp;</span> pm;             <span class='comment'>// <i >exposition only</i></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.lock.guard-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.guard-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7463'>#</a></div><div class='texpara'><div id='thread.lock.guard-1.sentence-1' class='sentence'>An object of type <span class='texttt'>lock_<span class='shy'></span>guard</span> controls the ownership of a lockable object
within a scope<a class='hidden_link' href='#thread.lock.guard-1.sentence-1'>.</a></div> <div id='thread.lock.guard-1.sentence-2' class='sentence'>A <span class='texttt'>lock_<span class='shy'></span>guard</span> object maintains ownership of a lockable
object throughout the <span class='texttt'>lock_<span class='shy'></span>guard</span> object's <a href='basic.life#def:lifetime' title='6.7.4&emsp;Lifetime&emsp;[basic.life]'>lifetime</a><a class='hidden_link' href='#thread.lock.guard-1.sentence-2'>.</a></div> <div id='thread.lock.guard-1.sentence-3' class='sentence'>The behavior of a program is undefined if the lockable object referenced by
<span class='texttt'>pm</span> does not exist for the entire lifetime of the <span class='texttt'>lock_<span class='shy'></span>guard</span>
object<a class='hidden_link' href='#thread.lock.guard-1.sentence-3'>.</a></div> <div id='thread.lock.guard-1.sentence-4' class='sentence'>The supplied <span class='texttt'>Mutex</span> type shall meet the <a href='thread.req.lockable.basic#:Cpp17BasicLockable' title='32.2.5.2&emsp;Cpp17BasicLockable requirements&emsp;[thread.req.lockable.basic]'><i >Cpp17BasicLockable</i></a>
requirements (<a href='thread.req.lockable.basic' title='32.2.5.2&emsp;Cpp17BasicLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>basic]</a>)<a class='hidden_link' href='#thread.lock.guard-1.sentence-4'>.</a></div></div></div><div class='texpara'><div id='lib:lock_guard,constructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:lock_guard,constructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>explicit</span> lock_guard<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.guard-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.guard-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7478'>#</a></div><div class='texpara'><div id='thread.lock.guard-2.sentence-1' class='sentence'><i >Effects</i>: Initializes <span class='texttt'>pm</span> with <span class='texttt'>m</span><a class='hidden_link' href='#thread.lock.guard-2.sentence-1'>.</a></div> <div id='thread.lock.guard-2.sentence-2' class='sentence'>Calls <span class='texttt'>m<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.guard-2.sentence-2'>.</a></div></div></div></div><div class='texpara'><div id='lib:lock_guard,constructor_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:lock_guard,constructor_'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>lock_guard<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, adopt_lock_t<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.guard-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.guard-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7489'>#</a></div><div class='texpara'><div id='thread.lock.guard-3.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread holds a non-shared lock on <span class='texttt'>m</span><a class='hidden_link' href='#thread.lock.guard-3.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.guard-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.guard-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7493'>#</a></div><div class='texpara'><div id='thread.lock.guard-4.sentence-1' class='sentence'><i >Effects</i>: Initializes <span class='texttt'>pm</span> with <span class='texttt'>m</span><a class='hidden_link' href='#thread.lock.guard-4.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.guard-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.guard-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7497'>#</a></div><div class='texpara'><div id='thread.lock.guard-5.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#thread.lock.guard-5.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:lock_guard,destructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:lock_guard,destructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='operator'>~</span>lock_guard<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.guard-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.guard-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7508'>#</a></div><div class='texpara'><div id='thread.lock.guard-6.sentence-1' class='sentence'><i >Effects</i>: Equivalent to: <span class='texttt'>pm<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span></div></div></div></div></div><div id='thread.lock.scoped' class='section'><h4 ><a class='secnum' href='#thread.lock.scoped' style='min-width:95pt'>32.6.5.3</a> Class template <span class='texttt'>scoped_<span class='shy'></span>lock</span> <a class='abbr_ref' href='thread.lock.scoped'>[thread.lock.scoped]</a></h4><div class='texpara'><span id='lib:scoped_lock'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:scoped_lock'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> MutexTypes<span class='anglebracket'>&gt;</span>
  <span class='keyword'>class</span> scoped_lock <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class='keyword'>using</span> mutex_type <span class='operator'>=</span> <i ><span class='texttt'>see below</span></i>;     <span class='comment'>// Only if <span class='tcode_in_codeblock'>sizeof...(MutexTypes) == 1</span> is <span class='tcode_in_codeblock'>true</span></span>

    <span class="added">constexpr </span><span class='keyword'>explicit</span> scoped_lock<span class='parenthesis'>(</span>MutexTypes<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> m<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>explicit</span> scoped_lock<span class='parenthesis'>(</span>adopt_lock_t, MutexTypes<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> m<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>scoped_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    scoped_lock<span class='parenthesis'>(</span><span class='keyword'>const</span> scoped_lock<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    scoped_lock<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> scoped_lock<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

  <span class='keyword'>private</span><span class='operator'>:</span>
    tuple<span class='anglebracket'>&lt;</span>MutexTypes<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='anglebracket'>&gt;</span> pm;   <span class='comment'>// <i >exposition only</i></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.lock.scoped-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.scoped-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7536'>#</a></div><div class='texpara'><div id='thread.lock.scoped-1.sentence-1' class='sentence'>An object of type <span class='texttt'>scoped_<span class='shy'></span>lock</span> controls the ownership of lockable objects
within a scope<a class='hidden_link' href='#thread.lock.scoped-1.sentence-1'>.</a></div> <div id='thread.lock.scoped-1.sentence-2' class='sentence'>A <span class='texttt'>scoped_<span class='shy'></span>lock</span> object maintains ownership of lockable
objects throughout the <span class='texttt'>scoped_<span class='shy'></span>lock</span> object's <a href='basic.life#def:lifetime' title='6.7.4&emsp;Lifetime&emsp;[basic.life]'>lifetime</a><a class='hidden_link' href='#thread.lock.scoped-1.sentence-2'>.</a></div> <div id='thread.lock.scoped-1.sentence-3' class='sentence'>The behavior of a program is undefined if the lockable objects referenced by
<span class='texttt'>pm</span> do not exist for the entire lifetime of the <span class='texttt'>scoped_<span class='shy'></span>lock</span>
object<a class='hidden_link' href='#thread.lock.scoped-1.sentence-3'>.</a></div> <ul class='itemize'><li id='thread.lock.scoped-1.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.lock.scoped-1.1'>(1.1)</a></div><div class='texpara'><div id='thread.lock.scoped-1.1.sentence-1' class='sentence'>If <span class='texttt'><span class='keyword'>sizeof</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>(</span>MutexTypes<span class='parenthesis'>)</span></span> is one,
let <span class='texttt'>Mutex</span> denote the sole type constituting the pack <span class='texttt'>MutexTypes</span><a class='hidden_link' href='#thread.lock.scoped-1.1.sentence-1'>.</a></div> <div id='thread.lock.scoped-1.1.sentence-2' class='sentence'><span class='texttt'>Mutex</span>
shall meet the <a href='thread.req.lockable.basic#:Cpp17BasicLockable' title='32.2.5.2&emsp;Cpp17BasicLockable requirements&emsp;[thread.req.lockable.basic]'><i >Cpp17BasicLockable</i></a> requirements (<a href='thread.req.lockable.basic' title='32.2.5.2&emsp;Cpp17BasicLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>basic]</a>)<a class='hidden_link' href='#thread.lock.scoped-1.1.sentence-2'>.</a></div> <div id='thread.lock.scoped-1.1.sentence-3' class='sentence'>The member <a href='dcl.typedef#nt:typedef-name' title='9.2.4&emsp;The typedef specifier&emsp;[dcl.typedef]'><span id='ntref:typedef-name'><span class='textsf'><i >typedef-name</i></span></span></a> <span class='texttt'>mutex_<span class='shy'></span>type</span>
denotes the same type as <span class='texttt'>Mutex</span><a class='hidden_link' href='#thread.lock.scoped-1.1.sentence-3'>.</a></div></div></li><li id='thread.lock.scoped-1.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#thread.lock.scoped-1.2'>(1.2)</a></div><div class='texpara'><div id='thread.lock.scoped-1.2.sentence-1' class='sentence'>Otherwise, all types in the template parameter pack <span class='texttt'>MutexTypes</span>
shall meet the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a> requirements (<a href='thread.req.lockable.req' title='32.2.5.3&emsp;Cpp17Lockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>req]</a>)
and there is no member <span class='texttt'>mutex_<span class='shy'></span>type</span><a class='hidden_link' href='#thread.lock.scoped-1.2.sentence-1'>.</a></div></div></li></ul></div></div><div class='texpara'><div id='lib:scoped_lock,constructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:scoped_lock,constructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>explicit</span> scoped_lock<span class='parenthesis'>(</span>MutexTypes<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> m<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.scoped-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.scoped-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7563'>#</a></div><div class='texpara'><div id='thread.lock.scoped-2.sentence-1' class='sentence'><i >Effects</i>: Initializes <span class='texttt'>pm</span> with <span class='texttt'>tie<span class='parenthesis'>(</span>m<span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.scoped-2.sentence-1'>.</a></div> <div id='thread.lock.scoped-2.sentence-2' class='sentence'>Then if <span class='texttt'><span class='keyword'>sizeof</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>(</span>MutexTypes<span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>0</span></span>, no effects<a class='hidden_link' href='#thread.lock.scoped-2.sentence-2'>.</a></div> <div id='thread.lock.scoped-2.sentence-3' class='sentence'>Otherwise if <span class='texttt'><span class='keyword'>sizeof</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>(</span>MutexTypes<span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>1</span></span>, then <span class='texttt'>m<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.scoped-2.sentence-3'>.</a></div> <div id='thread.lock.scoped-2.sentence-4' class='sentence'>Otherwise, <span class='texttt'>lock<span class='parenthesis'>(</span>m<span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.scoped-2.sentence-4'>.</a></div></div></div></div><div class='texpara'><div id='lib:scoped_lock,constructor_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:scoped_lock,constructor_'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>explicit</span> scoped_lock<span class='parenthesis'>(</span>adopt_lock_t, MutexTypes<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> m<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.scoped-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.scoped-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7577'>#</a></div><div class='texpara'><div id='thread.lock.scoped-3.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread holds a non-shared lock on each element of <span class='texttt'>m</span><a class='hidden_link' href='#thread.lock.scoped-3.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.scoped-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.scoped-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7581'>#</a></div><div class='texpara'><div id='thread.lock.scoped-4.sentence-1' class='sentence'><i >Effects</i>: Initializes <span class='texttt'>pm</span> with <span class='texttt'>tie<span class='parenthesis'>(</span>m<span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.scoped-4.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.scoped-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.scoped-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7585'>#</a></div><div class='texpara'><div id='thread.lock.scoped-5.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#thread.lock.scoped-5.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:scoped_lock,destructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:scoped_lock,destructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='operator'>~</span>scoped_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.scoped-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.scoped-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7596'>#</a></div><div class='texpara'><div id='thread.lock.scoped-6.sentence-1' class='sentence'><i >Effects</i>: For all <span class='texttt'>i</span> in [<span class='texttt'><span class='literal'>0</span>, <span class='keyword'>sizeof</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>(</span>MutexTypes<span class='parenthesis'>)</span></span>),
<span class='texttt'>get<span class='anglebracket'>&lt;</span>i<span class='anglebracket'>&gt;</span><span class='parenthesis'>(</span>pm<span class='parenthesis'>)</span><span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.scoped-6.sentence-1'>.</a></div></div></div></div></div><div id='thread.lock.unique' class='section'><h4 ><a class='secnum' href='#thread.lock.unique' style='min-width:95pt'>32.6.5.4</a> Class template <span class='texttt'>unique_<span class='shy'></span>lock</span> <a class='abbr_ref' href='thread.lock.unique'>[thread.lock.unique]</a></h4><div id='thread.lock.unique.general' class='section'><h4 ><a class='secnum' href='#thread.lock.unique.general' style='min-width:110pt'>32.6.5.4.1</a> General <a class='abbr_ref' href='thread.lock.unique.general'>[thread.lock.unique.general]</a></h4><div class='texpara'><span id='lib:unique_lock'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span>
  <span class='keyword'>class</span> unique_lock <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class='keyword'>using</span> mutex_type <span class='operator'>=</span> Mutex;

    <span class='comment'>// <a href='#thread.lock.unique.cons' title='32.6.5.4.2&emsp;Constructors, destructor, and assignment'>[thread.<span class='shy'></span>lock.<span class='shy'></span>unique.<span class='shy'></span>cons]</a>, construct/copy/destroy</span>
    <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>explicit</span> unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, defer_lock_t<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, try_to_lock_t<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, adopt_lock_t<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>unique_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    unique_lock<span class='parenthesis'>(</span><span class='keyword'>const</span> unique_lock<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    unique_lock<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> unique_lock<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>unique_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>unique_lock<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span>unique_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;

    <span class='comment'>// <a href='#thread.lock.unique.locking' title='32.6.5.4.3&emsp;Locking'>[thread.<span class='shy'></span>lock.<span class='shy'></span>unique.<span class='shy'></span>locking]</a>, locking</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;

    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='comment'>// <a href='#thread.lock.unique.mod' title='32.6.5.4.4&emsp;Modifiers'>[thread.<span class='shy'></span>lock.<span class='shy'></span>unique.<span class='shy'></span>mod]</a>, modifiers</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>unique_lock<span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>mutex_type<span class='operator'>*</span> release<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;

    <span class='comment'>// <a href='#thread.lock.unique.obs' title='32.6.5.4.5&emsp;Observers'>[thread.<span class='shy'></span>lock.<span class='shy'></span>unique.<span class='shy'></span>obs]</a>, observers</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> owns_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>explicit</span> <span class='keyword'>operator</span> <span class='keyword'>bool</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>mutex_type<span class='operator'>*</span> mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;

  <span class='keyword'>private</span><span class='operator'>:</span>
    mutex_type<span class='operator'>*</span> pm;             <span class='comment'>// <i >exposition only</i></span>
    <span class='keyword'>bool</span> owns;                  <span class='comment'>// <i >exposition only</i></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.lock.unique.general-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7659'>#</a></div><div class='texpara'><div id='thread.lock.unique.general-1.sentence-1' class='sentence'>An object of type <span class='texttt'>unique_<span class='shy'></span>lock</span> controls the ownership of a lockable
object within a scope<a class='hidden_link' href='#thread.lock.unique.general-1.sentence-1'>.</a></div> <div id='thread.lock.unique.general-1.sentence-2' class='sentence'>Ownership of the lockable object may be acquired at
construction or after construction, and may be transferred, after
acquisition, to another <span class='texttt'>unique_<span class='shy'></span>lock</span> object<a class='hidden_link' href='#thread.lock.unique.general-1.sentence-2'>.</a></div> <div id='thread.lock.unique.general-1.sentence-3' class='sentence'>Objects of type <span class='texttt'>unique_<span class='shy'></span>lock</span> are not
copyable but are movable<a class='hidden_link' href='#thread.lock.unique.general-1.sentence-3'>.</a></div> <div id='thread.lock.unique.general-1.sentence-4' class='sentence'>The behavior of a program is undefined if the contained pointer
<span class='texttt'>pm</span> is not null and the lockable object pointed
to by <span class='texttt'>pm</span> does not exist for the entire remaining
lifetime (<a href='basic.life' title='6.7.4&emsp;Lifetime'>[basic.<span class='shy'></span>life]</a>) of the <span class='texttt'>unique_<span class='shy'></span>lock</span> object<a class='hidden_link' href='#thread.lock.unique.general-1.sentence-4'>.</a></div> <div id='thread.lock.unique.general-1.sentence-5' class='sentence'>The supplied
<span class='texttt'>Mutex</span> type shall meet the <a href='thread.req.lockable.basic#:Cpp17BasicLockable' title='32.2.5.2&emsp;Cpp17BasicLockable requirements&emsp;[thread.req.lockable.basic]'><i >Cpp17BasicLockable</i></a>
requirements (<a href='thread.req.lockable.basic' title='32.2.5.2&emsp;Cpp17BasicLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>basic]</a>)<a class='hidden_link' href='#thread.lock.unique.general-1.sentence-5'>.</a></div></div></div><div class='para nonNormativeOnly' id='thread.lock.unique.general-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7671'>#</a></div><div class='texpara'><div id='thread.lock.unique.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.lock.unique.general-note-1'>1</a></i>:&ensp;<div id='thread.lock.unique.general-2.sentence-1' class='sentence'><span class='texttt'>unique_<span class='shy'></span>lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span></span> meets the <a href='thread.req.lockable.basic#:Cpp17BasicLockable' title='32.2.5.2&emsp;Cpp17BasicLockable requirements&emsp;[thread.req.lockable.basic]'><i >Cpp17BasicLockable</i></a> requirements<a class='hidden_link' href='#thread.lock.unique.general-2.sentence-1'>.</a></div> <div id='thread.lock.unique.general-2.sentence-2' class='sentence'>If <span class='texttt'>Mutex</span>
meets the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a> requirements (<a href='thread.req.lockable.req' title='32.2.5.3&emsp;Cpp17Lockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>req]</a>),
<span class='texttt'>unique_<span class='shy'></span>lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span></span> also meets the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a> requirements;
if <span class='texttt'>Mutex</span>
meets the <a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a> requirements (<a href='thread.req.lockable.timed' title='32.2.5.4&emsp;Cpp17TimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>timed]</a>),
<span class='texttt'>unique_<span class='shy'></span>lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span></span> also meets the <a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a> requirements<a class='hidden_link' href='#thread.lock.unique.general-2.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div id='thread.lock.unique.cons' class='section'><h4 ><a class='secnum' href='#thread.lock.unique.cons' style='min-width:110pt'>32.6.5.4.2</a> Constructors, destructor, and assignment <a class='abbr_ref' href='thread.lock.unique.cons'>[thread.lock.unique.cons]</a></h4><div class='texpara'><div id='lib:unique_lock,constructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7689'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-1.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>nullptr</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.unique.cons-1.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,constructor_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor_'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>explicit</span> unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7700'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-2.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7704'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-3.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.unique.cons-3.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,constructor__'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor__'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, defer_lock_t<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7715'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-4.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.unique.cons-4.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,constructor___'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor___'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, try_to_lock_t<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7726'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-5.sentence-1' class='sentence'><i >Preconditions</i>: The supplied <span class='texttt'>Mutex</span> type meets the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a>
requirements (<a href='thread.req.lockable.req' title='32.2.5.3&emsp;Cpp17Lockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>req]</a>)<a class='hidden_link' href='#thread.lock.unique.cons-5.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7731'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-6.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-6.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7735'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-7.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>,
where <span class='texttt'>res</span> is the value returned by the call to <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-7.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,constructor____'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor____'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, adopt_lock_t<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7747'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-8.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread holds a non-shared lock on <span class='texttt'>m</span><a class='hidden_link' href='#thread.lock.unique.cons-8.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7751'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-9.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.unique.cons-9.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7755'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-10.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#thread.lock.unique.cons-10.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,constructor_____'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor_____'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7767'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-11.sentence-1' class='sentence'><i >Preconditions</i>: The supplied <span class='texttt'>Mutex</span> type meets the
<a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a> requirements (<a href='thread.req.lockable.timed' title='32.2.5.4&emsp;Cpp17TimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.unique.cons-11.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7772'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-12.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7776'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-13.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>,
where <span class='texttt'>res</span> is
the value returned by the call to <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-13.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,constructor______'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor______'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7790'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-14.sentence-1' class='sentence'><i >Preconditions</i>: The supplied <span class='texttt'>Mutex</span> type meets the <a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a> requirements (<a href='thread.req.lockable.timed' title='32.2.5.4&emsp;Cpp17TimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.unique.cons-14.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7794'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-15.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-15.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.cons-16'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7798'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-16.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>,
where <span class='texttt'>res</span> is the value returned by the call to <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-16.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,constructor_______'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,constructor_______'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>unique_lock<span class='parenthesis'>(</span>unique_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-17'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-17'>17</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7810'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-17.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> u_<span class='shy'></span>p<span class='operator'>.</span>pm</span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> u_<span class='shy'></span>p<span class='operator'>.</span>owns</span> (where <span class='texttt'>u_<span class='shy'></span>p</span> is the state of <span class='texttt'>u</span> just prior to this construction),  <span class='texttt'>u<span class='operator'>.</span>pm <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>0</span></span> and <span class='texttt'>u<span class='operator'>.</span>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.unique.cons-17.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,operator='><div id='lib:operator=,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:operator=,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>unique_lock<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span>unique_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.cons-18'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7821'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-18.sentence-1' class='sentence'><i >Effects</i>: Equivalent to: <span class='texttt'>unique_<span class='shy'></span>lock<span class='parenthesis'>(</span>std<span class='operator'>&#x200b;::&#x200b;</span>move<span class='parenthesis'>(</span>u<span class='parenthesis'>)</span><span class='parenthesis'>)</span><span class='operator'>.</span>swap<span class='parenthesis'>(</span><span class='operator'>*</span><span class='keyword'>this</span><span class='parenthesis'>)</span></span></div></div></div></div><div class='para' id='thread.lock.unique.cons-19'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-19'>19</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7825'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-19.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#thread.lock.unique.cons-19.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,destructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unique_lock,destructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='operator'>~</span>unique_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.unique.cons-20'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.cons-20'>20</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7836'>#</a></div><div class='texpara'><div id='thread.lock.unique.cons-20.sentence-1' class='sentence'><i >Effects</i>: If <span class='texttt'>owns</span> calls <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.cons-20.sentence-1'>.</a></div></div></div></div></div><div id='thread.lock.unique.locking' class='section'><h4 ><a class='secnum' href='#thread.lock.unique.locking' style='min-width:110pt'>32.6.5.4.3</a> Locking <a class='abbr_ref' href='thread.lock.unique.locking'>[thread.lock.unique.locking]</a></h4><div class='texpara'><div id='lib:unique_lock,lock'><div id='lib:lock,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:lock,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.locking-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7849'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-1.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-1.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7853'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-2.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.unique.locking-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7857'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-3.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-3.sentence-1'>.</a></div> <div id='thread.lock.unique.locking-3.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an exception
is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-3.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7862'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-4.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.unique.locking-4.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-4.1'>(4.1)</a></div><div class='texpara'><div id='thread.lock.unique.locking-4.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.unique.locking-4.1.sentence-1'>.</a></div></div></li><li id='thread.lock.unique.locking-4.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-4.2'>(4.2)</a></div><div class='texpara'><div id='thread.lock.unique.locking-4.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span>
is <span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.unique.locking-4.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:unique_lock,try_lock'><div id='lib:try_lock,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:try_lock,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.locking-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7877'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-5.sentence-1' class='sentence'><i >Preconditions</i>: The supplied <span class='texttt'>Mutex</span> meets the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a>
requirements (<a href='thread.req.lockable.req' title='32.2.5.3&emsp;Cpp17Lockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>req]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-5.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7882'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-6.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-6.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7886'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-7.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>, where <span class='texttt'>res</span> is the value returned by
<span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-7.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7891'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-8.sentence-1' class='sentence'><i >Returns</i>: The value returned by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-8.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7895'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-9.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-9.sentence-1'>.</a></div> <div id='thread.lock.unique.locking-9.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an exception
is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-9.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7900'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-10.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.unique.locking-10.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-10.1'>(10.1)</a></div><div class='texpara'><div id='thread.lock.unique.locking-10.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr_'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.unique.locking-10.1.sentence-1'>.</a></div></div></li><li id='thread.lock.unique.locking-10.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-10.2'>(10.2)</a></div><div class='texpara'><div id='thread.lock.unique.locking-10.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span>
is <span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.unique.locking-10.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:unique_lock,try_lock_until'><div id='lib:try_lock_until,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:try_lock_until,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.locking-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7916'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-11.sentence-1' class='sentence'><i >Preconditions</i>: The supplied <span class='texttt'>Mutex</span> type meets the <a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a>
requirements (<a href='thread.req.lockable.timed' title='32.2.5.4&emsp;Cpp17TimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-11.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7921'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-12.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7925'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-13.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>, where <span class='texttt'>res</span> is the value returned by
<span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-13.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7930'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-14.sentence-1' class='sentence'><i >Returns</i>: The value returned by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-14.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7934'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-15.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>until<span class='parenthesis'>(</span>abstime<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-15.sentence-1'>.</a></div> <div id='thread.lock.unique.locking-15.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an
exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-15.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-16'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7939'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-16.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.unique.locking-16.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-16.1'>(16.1)</a></div><div class='texpara'><div id='thread.lock.unique.locking-16.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr__'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.unique.locking-16.1.sentence-1'>.</a></div></div></li><li id='thread.lock.unique.locking-16.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-16.2'>(16.2)</a></div><div class='texpara'><div id='thread.lock.unique.locking-16.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span> is
<span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.unique.locking-16.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:unique_lock,try_lock_for'><div id='lib:try_lock_for,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:try_lock_for,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.locking-17'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-17'>17</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7955'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-17.sentence-1' class='sentence'><i >Preconditions</i>: The supplied <span class='texttt'>Mutex</span> type meets the <a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a> requirements (<a href='thread.req.lockable.timed' title='32.2.5.4&emsp;Cpp17TimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-17.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-18'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7959'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-18.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-18.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-19'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-19'>19</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7963'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-19.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>, where <span class='texttt'>res</span> is the value returned by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-19.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-20'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-20'>20</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7967'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-20.sentence-1' class='sentence'><i >Returns</i>: The value returned by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-20.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-21'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-21'>21</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7971'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-21.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-21.sentence-1'>.</a></div> <div id='thread.lock.unique.locking-21.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an
exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-21.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-22'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-22'>22</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7976'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-22.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.unique.locking-22.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-22.1'>(22.1)</a></div><div class='texpara'><div id='thread.lock.unique.locking-22.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr___'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.unique.locking-22.1.sentence-1'>.</a></div></div></li><li id='thread.lock.unique.locking-22.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-22.2'>(22.2)</a></div><div class='texpara'><div id='thread.lock.unique.locking-22.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span> is
<span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.unique.locking-22.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:unique_lock,unlock'><div id='lib:unlock,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unlock,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.locking-23'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-23'>23</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7991'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-23.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.locking-23.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-24'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-24'>24</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7995'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-24.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.unique.locking-24.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-25'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-25'>25</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L7999'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-25.sentence-1' class='sentence'><i >Throws</i>: <span class='texttt'>system_<span class='shy'></span>error</span> when
an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.unique.locking-25.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.locking-26'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.locking-26'>26</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8004'>#</a></div><div class='texpara'><div id='thread.lock.unique.locking-26.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.unique.locking-26.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.unique.locking-26.1'>(26.1)</a></div><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if on entry <span class='texttt'>owns</span> is <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.unique.locking-26.sentence-1'>.</a></li></ul></div></div></div></div></div><div id='thread.lock.unique.mod' class='section'><h4 ><a class='secnum' href='#thread.lock.unique.mod' style='min-width:110pt'>32.6.5.4.4</a> Modifiers <a class='abbr_ref' href='thread.lock.unique.mod'>[thread.lock.unique.mod]</a></h4><div class='texpara'><div id='lib:unique_lock,swap'><div id='lib:swap,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:swap,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>unique_lock<span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.mod-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.mod-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8019'>#</a></div><div class='texpara'><div id='thread.lock.unique.mod-1.sentence-1' class='sentence'><i >Effects</i>: Swaps the data members of <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span> and <span class='texttt'>u</span><a class='hidden_link' href='#thread.lock.unique.mod-1.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,release'><div id='lib:release,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:release,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>mutex_type<span class='operator'>*</span> release<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.mod-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.mod-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8030'>#</a></div><div class='texpara'><div id='thread.lock.unique.mod-2.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>0</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.unique.mod-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.unique.mod-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.mod-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8034'>#</a></div><div class='texpara'><div id='thread.lock.unique.mod-3.sentence-1' class='sentence'><i >Returns</i>: The previous value of <span class='texttt'>pm</span><a class='hidden_link' href='#thread.lock.unique.mod-3.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,swap_'><div id='lib:swap,unique_lock_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:swap,unique_lock_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> x, unique_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> y<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.mod-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.mod-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8046'>#</a></div><div class='texpara'><div id='thread.lock.unique.mod-4.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>x<span class='operator'>.</span>swap<span class='parenthesis'>(</span>y<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.unique.mod-4.sentence-1'>.</a></div></div></div></div></div><div id='thread.lock.unique.obs' class='section'><h4 ><a class='secnum' href='#thread.lock.unique.obs' style='min-width:110pt'>32.6.5.4.5</a> Observers <a class='abbr_ref' href='thread.lock.unique.obs'>[thread.lock.unique.obs]</a></h4><div class='texpara'><div id='lib:unique_lock,owns_lock'><div id='lib:owns_lock,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:owns_lock,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>bool</span> owns_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.obs-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.obs-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8059'>#</a></div><div class='texpara'><div id='thread.lock.unique.obs-1.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>owns</span><a class='hidden_link' href='#thread.lock.unique.obs-1.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,operator_bool'><div id='lib:operator_bool,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:operator_bool,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>explicit</span> <span class='keyword'>operator</span> <span class='keyword'>bool</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.obs-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.obs-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8070'>#</a></div><div class='texpara'><div id='thread.lock.unique.obs-2.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>owns</span><a class='hidden_link' href='#thread.lock.unique.obs-2.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:unique_lock,mutex'><div id='lib:mutex,unique_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:mutex,unique_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>mutex_type <span class='operator'>*</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.unique.obs-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.unique.obs-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8081'>#</a></div><div class='texpara'><div id='thread.lock.unique.obs-3.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>pm</span><a class='hidden_link' href='#thread.lock.unique.obs-3.sentence-1'>.</a></div></div></div></div></div></div><div id='thread.lock.shared' class='section'><h4 ><a class='secnum' href='#thread.lock.shared' style='min-width:95pt'>32.6.5.5</a> Class template <span class='texttt'>shared_<span class='shy'></span>lock</span> <a class='abbr_ref' href='thread.lock.shared'>[thread.lock.shared]</a></h4><div id='thread.lock.shared.general' class='section'><h4 ><a class='secnum' href='#thread.lock.shared.general' style='min-width:110pt'>32.6.5.5.1</a> General <a class='abbr_ref' href='thread.lock.shared.general'>[thread.lock.shared.general]</a></h4><div class='texpara'><span id='lib:shared_lock'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span>
  <span class='keyword'>class</span> shared_lock <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class='keyword'>using</span> mutex_type <span class='operator'>=</span> Mutex;

    <span class='comment'>// <a href='#thread.lock.shared.cons' title='32.6.5.5.2&emsp;Constructors, destructor, and assignment'>[thread.<span class='shy'></span>lock.<span class='shy'></span>shared.<span class='shy'></span>cons]</a>, construct/copy/destroy</span>
    <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>explicit</span> shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m<span class='parenthesis'>)</span>;        <span class='comment'>// blocking</span>
    <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, defer_lock_t<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, try_to_lock_t<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, adopt_lock_t<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>shared_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    shared_lock<span class='parenthesis'>(</span><span class='keyword'>const</span> shared_lock<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    shared_lock<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> shared_lock<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>shared_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>shared_lock<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span>shared_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;

    <span class='comment'>// <a href='#thread.lock.shared.locking' title='32.6.5.5.3&emsp;Locking'>[thread.<span class='shy'></span>lock.<span class='shy'></span>shared.<span class='shy'></span>locking]</a>, locking</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                                <span class='comment'>// blocking</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    <span class='comment'>// <a href='#thread.lock.shared.mod' title='32.6.5.5.4&emsp;Modifiers'>[thread.<span class='shy'></span>lock.<span class='shy'></span>shared.<span class='shy'></span>mod]</a>, modifiers</span>
    <span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>shared_lock<span class='operator'>&amp;</span> u<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>mutex_type<span class='operator'>*</span> release<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;

    <span class='comment'>// <a href='#thread.lock.shared.obs' title='32.6.5.5.5&emsp;Observers'>[thread.<span class='shy'></span>lock.<span class='shy'></span>shared.<span class='shy'></span>obs]</a>, observers</span>
    <span class="added">constexpr </span><span class='keyword'>bool</span> owns_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>explicit</span> <span class='keyword'>operator</span> <span class='keyword'>bool</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span>mutex_type<span class='operator'>*</span> mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;

  <span class='keyword'>private</span><span class='operator'>:</span>
    mutex_type<span class='operator'>*</span> pm;                             <span class='comment'>// <i >exposition only</i></span>
    <span class='keyword'>bool</span> owns;                                  <span class='comment'>// <i >exposition only</i></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.lock.shared.general-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8141'>#</a></div><div class='texpara'><div id='thread.lock.shared.general-1.sentence-1' class='sentence'>An object of type <span class='texttt'>shared_<span class='shy'></span>lock</span> controls the shared ownership of a
lockable object within a scope<a class='hidden_link' href='#thread.lock.shared.general-1.sentence-1'>.</a></div> <div id='thread.lock.shared.general-1.sentence-2' class='sentence'>Shared ownership of the lockable object may be
acquired at construction or after construction, and may be transferred, after
acquisition, to another <span class='texttt'>shared_<span class='shy'></span>lock</span> object<a class='hidden_link' href='#thread.lock.shared.general-1.sentence-2'>.</a></div> <div id='thread.lock.shared.general-1.sentence-3' class='sentence'>Objects of type
<span class='texttt'>shared_<span class='shy'></span>lock</span> are not copyable but are movable<a class='hidden_link' href='#thread.lock.shared.general-1.sentence-3'>.</a></div> <div id='thread.lock.shared.general-1.sentence-4' class='sentence'>The behavior of a program
is undefined if the contained pointer <span class='texttt'>pm</span> is not null and the lockable
object pointed to by <span class='texttt'>pm</span> does not exist for the entire remaining
lifetime (<a href='basic.life' title='6.7.4&emsp;Lifetime'>[basic.<span class='shy'></span>life]</a>) of the <span class='texttt'>shared_<span class='shy'></span>lock</span> object<a class='hidden_link' href='#thread.lock.shared.general-1.sentence-4'>.</a></div> <div id='thread.lock.shared.general-1.sentence-5' class='sentence'>The supplied
<span class='texttt'>Mutex</span> type shall meet the <a href='thread.req.lockable.shared#:Cpp17SharedLockable' title='32.2.5.5&emsp;Cpp17SharedLockable requirements&emsp;[thread.req.lockable.shared]'><i >Cpp17SharedLockable</i></a>
requirements (<a href='thread.req.lockable.shared' title='32.2.5.5&emsp;Cpp17SharedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared]</a>)<a class='hidden_link' href='#thread.lock.shared.general-1.sentence-5'>.</a></div></div></div><div class='para nonNormativeOnly' id='thread.lock.shared.general-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8153'>#</a></div><div class='texpara'><div id='thread.lock.shared.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.lock.shared.general-note-1'>1</a></i>:&ensp;<div id='thread.lock.shared.general-2.sentence-1' class='sentence'><span class='texttt'>shared_<span class='shy'></span>lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span></span> meets the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a>
requirements (<a href='thread.req.lockable.req' title='32.2.5.3&emsp;Cpp17Lockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>req]</a>)<a class='hidden_link' href='#thread.lock.shared.general-2.sentence-1'>.</a></div> <div id='thread.lock.shared.general-2.sentence-2' class='sentence'>If <span class='texttt'>Mutex</span> meets the <a href='thread.req.lockable.shared.timed#:Cpp17SharedTimedLockable' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements&emsp;[thread.req.lockable.shared.timed]'><i >Cpp17SharedTimedLockable</i></a>
requirements (<a href='thread.req.lockable.shared.timed' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared.<span class='shy'></span>timed]</a>),
<span class='texttt'>shared_<span class='shy'></span>lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span></span> also meets the <a href='thread.req.lockable.timed#:Cpp17TimedLockable' title='32.2.5.4&emsp;Cpp17TimedLockable requirements&emsp;[thread.req.lockable.timed]'><i >Cpp17TimedLockable</i></a>
requirements (<a href='thread.req.lockable.timed' title='32.2.5.4&emsp;Cpp17TimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.shared.general-2.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div id='thread.lock.shared.cons' class='section'><h4 ><a class='secnum' href='#thread.lock.shared.cons' style='min-width:110pt'>32.6.5.5.2</a> Constructors, destructor, and assignment <a class='abbr_ref' href='thread.lock.shared.cons'>[thread.lock.shared.cons]</a></h4><div class='texpara'><div id='lib:shared_lock,constructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8171'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-1.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>nullptr</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.shared.cons-1.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,constructor_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor_'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>explicit</span> shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8182'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-2.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.cons-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8186'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-3.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.shared.cons-3.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,constructor__'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor__'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, defer_lock_t<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8197'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-4.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.shared.cons-4.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,constructor___'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor___'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, try_to_lock_t<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8208'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-5.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-5.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.cons-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8212'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-6.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>
where <span class='texttt'>res</span> is the
value returned by the call to <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-6.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,constructor____'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor____'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m, adopt_lock_t<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8225'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-7.sentence-1' class='sentence'><i >Preconditions</i>: The calling thread holds a shared lock on <span class='texttt'>m</span><a class='hidden_link' href='#thread.lock.shared.cons-7.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.cons-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8229'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-8.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.shared.cons-8.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,constructor_____'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor_____'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m,
              <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8242'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-9.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>Mutex</span> meets the <a href='thread.req.lockable.shared.timed#:Cpp17SharedTimedLockable' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements&emsp;[thread.req.lockable.shared.timed]'><i >Cpp17SharedTimedLockable</i></a>
requirements (<a href='thread.req.lockable.shared.timed' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.shared.cons-9.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.cons-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8247'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-10.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-10.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.cons-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8251'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-11.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>
where <span class='texttt'>res</span>
is the value returned by the call to <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-11.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,constructor______'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor______'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>mutex_type<span class='operator'>&amp;</span> m,
              <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8266'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-12.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>Mutex</span> meets the <a href='thread.req.lockable.shared.timed#:Cpp17SharedTimedLockable' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements&emsp;[thread.req.lockable.shared.timed]'><i >Cpp17SharedTimedLockable</i></a>
requirements (<a href='thread.req.lockable.shared.timed' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.shared.cons-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.cons-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8271'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-13.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-13.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.cons-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8275'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-14.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> addressof<span class='parenthesis'>(</span>m<span class='parenthesis'>)</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>
where <span class='texttt'>res</span> is
the value returned by the call to <span class='texttt'>m<span class='operator'>.</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-14.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,destructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,destructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='operator'>~</span>shared_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8288'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-15.sentence-1' class='sentence'><i >Effects</i>: If <span class='texttt'>owns</span> calls <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>unlock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.cons-15.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,constructor_______'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:shared_lock,constructor_______'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>shared_lock<span class='parenthesis'>(</span>shared_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> sl<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div><div class='para' id='thread.lock.shared.cons-16'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8299'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-16.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> sl_<span class='shy'></span>p<span class='operator'>.</span>pm</span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> sl_<span class='shy'></span>p<span class='operator'>.</span>owns</span> (where
<span class='texttt'>sl_<span class='shy'></span>p</span> is the state of <span class='texttt'>sl</span> just prior to this construction),
<span class='texttt'>sl<span class='operator'>.</span>pm <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>nullptr</span></span> and <span class='texttt'>sl<span class='operator'>.</span>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.shared.cons-16.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,operator='><div id='lib:operator=,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:operator=,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>shared_lock<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span>shared_lock<span class='operator'>&amp;</span><span class='operator'>&amp;</span> sl<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.cons-17'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-17'>17</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8312'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-17.sentence-1' class='sentence'><i >Effects</i>: Equivalent to: <span class='texttt'>shared_<span class='shy'></span>lock<span class='parenthesis'>(</span>std<span class='operator'>&#x200b;::&#x200b;</span>move<span class='parenthesis'>(</span>sl<span class='parenthesis'>)</span><span class='parenthesis'>)</span><span class='operator'>.</span>swap<span class='parenthesis'>(</span><span class='operator'>*</span><span class='keyword'>this</span><span class='parenthesis'>)</span></span></div></div></div></div><div class='para' id='thread.lock.shared.cons-18'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.cons-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8316'>#</a></div><div class='texpara'><div id='thread.lock.shared.cons-18.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#thread.lock.shared.cons-18.sentence-1'>.</a></div></div></div></div></div><div id='thread.lock.shared.locking' class='section'><h4 ><a class='secnum' href='#thread.lock.shared.locking' style='min-width:110pt'>32.6.5.5.3</a> Locking <a class='abbr_ref' href='thread.lock.shared.locking'>[thread.lock.shared.locking]</a></h4><div class='texpara'><div id='lib:shared_lock,lock'><div id='lib:lock,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:lock,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.locking-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8329'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-1.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-1.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8333'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-2.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.shared.locking-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8337'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-3.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-3.sentence-1'>.</a></div> <div id='thread.lock.shared.locking-3.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.shared.locking-3.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8342'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-4.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.shared.locking-4.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-4.1'>(4.1)</a></div><div class='texpara'><div id='thread.lock.shared.locking-4.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr____'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.shared.locking-4.1.sentence-1'>.</a></div></div></li><li id='thread.lock.shared.locking-4.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-4.2'>(4.2)</a></div><div class='texpara'><div id='thread.lock.shared.locking-4.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span> is
<span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.shared.locking-4.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:shared_lock,try_lock'><div id='lib:try_lock,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:try_lock,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>bool</span> try_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.locking-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8357'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-5.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-5.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8361'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-6.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>, where <span class='texttt'>res</span> is the value returned by
the call to <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-6.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8366'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-7.sentence-1' class='sentence'><i >Returns</i>: The value returned by the call to <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-7.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8370'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-8.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-8.sentence-1'>.</a></div> <div id='thread.lock.shared.locking-8.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.shared.locking-8.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8375'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-9.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.shared.locking-9.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-9.1'>(9.1)</a></div><div class='texpara'><div id='thread.lock.shared.locking-9.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr_____'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.shared.locking-9.1.sentence-1'>.</a></div></div></li><li id='thread.lock.shared.locking-9.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-9.2'>(9.2)</a></div><div class='texpara'><div id='thread.lock.shared.locking-9.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span> is
<span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.shared.locking-9.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:shared_lock,try_lock_until'><div id='lib:try_lock_until,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:try_lock_until,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_until<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.locking-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8391'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-10.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>Mutex</span> meets the <a href='thread.req.lockable.shared.timed#:Cpp17SharedTimedLockable' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements&emsp;[thread.req.lockable.shared.timed]'><i >Cpp17SharedTimedLockable</i></a>
requirements (<a href='thread.req.lockable.shared.timed' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.shared.locking-10.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8396'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-11.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-11.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8400'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-12.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>, where <span class='texttt'>res</span> is the value returned by
the call to <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8405'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-13.sentence-1' class='sentence'><i >Returns</i>: The value returned by the call to
<span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-13.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8410'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-14.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>until<span class='parenthesis'>(</span>abs_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-14.sentence-1'>.</a></div> <div id='thread.lock.shared.locking-14.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.shared.locking-14.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8415'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-15.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.shared.locking-15.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-15.1'>(15.1)</a></div><div class='texpara'><div id='thread.lock.shared.locking-15.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr______'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.shared.locking-15.1.sentence-1'>.</a></div></div></li><li id='thread.lock.shared.locking-15.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-15.2'>(15.2)</a></div><div class='texpara'><div id='thread.lock.shared.locking-15.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span> is
<span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.shared.locking-15.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:shared_lock,try_lock_for'><div id='lib:try_lock_for,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:try_lock_for,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> try_lock_for<span class='parenthesis'>(</span><span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.locking-16'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8431'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-16.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>Mutex</span> meets the <a href='thread.req.lockable.shared.timed#:Cpp17SharedTimedLockable' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements&emsp;[thread.req.lockable.shared.timed]'><i >Cpp17SharedTimedLockable</i></a>
requirements (<a href='thread.req.lockable.shared.timed' title='32.2.5.6&emsp;Cpp17SharedTimedLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>shared.<span class='shy'></span>timed]</a>)<a class='hidden_link' href='#thread.lock.shared.locking-16.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-17'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-17'>17</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8436'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-17.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-17.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-18'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8440'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-18.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> res</span>, where <span class='texttt'>res</span> is the value returned by the call to <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-18.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-19'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-19'>19</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8444'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-19.sentence-1' class='sentence'><i >Returns</i>: The value returned by the call to <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-19.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-20'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-20'>20</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8448'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-20.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>try_<span class='shy'></span>lock_<span class='shy'></span>shared_<span class='shy'></span>for<span class='parenthesis'>(</span>rel_<span class='shy'></span>time<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-20.sentence-1'>.</a></div> <div id='thread.lock.shared.locking-20.sentence-2' class='sentence'><span class='texttt'>system_<span class='shy'></span>error</span> when an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.shared.locking-20.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-21'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-21'>21</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8452'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-21.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.shared.locking-21.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-21.1'>(21.1)</a></div><div class='texpara'><div id='thread.lock.shared.locking-21.1.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if <span class='texttt'>pm</span> is <span id=':nullptr_______'><span class='texttt'><span class='literal'>nullptr</span></span></span><a class='hidden_link' href='#thread.lock.shared.locking-21.1.sentence-1'>.</a></div></div></li><li id='thread.lock.shared.locking-21.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-21.2'>(21.2)</a></div><div class='texpara'><div id='thread.lock.shared.locking-21.2.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>deadlock_<span class='shy'></span>would_<span class='shy'></span>occur</span> — if on entry <span class='texttt'>owns</span> is
<span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.lock.shared.locking-21.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:shared_lock,unlock'><div id='lib:unlock,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:unlock,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.locking-22'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-22'>22</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8467'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-22.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>pm<span class='operator'>-</span><span class='anglebracket'>&gt;</span>unlock_<span class='shy'></span>shared<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.locking-22.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-23'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-23'>23</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8471'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-23.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.shared.locking-23.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-24'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-24'>24</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8475'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-24.sentence-1' class='sentence'><i >Throws</i>: <span class='texttt'>system_<span class='shy'></span>error</span> when an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#thread.lock.shared.locking-24.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.locking-25'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.locking-25'>25</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8479'>#</a></div><div class='texpara'><div id='thread.lock.shared.locking-25.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='thread.lock.shared.locking-25.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.lock.shared.locking-25.1'>(25.1)</a></div><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if on entry <span class='texttt'>owns</span> is
<span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.shared.locking-25.sentence-1'>.</a></li></ul></div></div></div></div></div><div id='thread.lock.shared.mod' class='section'><h4 ><a class='secnum' href='#thread.lock.shared.mod' style='min-width:110pt'>32.6.5.5.4</a> Modifiers <a class='abbr_ref' href='thread.lock.shared.mod'>[thread.lock.shared.mod]</a></h4><div class='texpara'><div id='lib:shared_lock,swap'><div id='lib:swap,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:swap,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>shared_lock<span class='operator'>&amp;</span> sl<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.mod-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.mod-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8495'>#</a></div><div class='texpara'><div id='thread.lock.shared.mod-1.sentence-1' class='sentence'><i >Effects</i>: Swaps the data members of <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span> and <span class='texttt'>sl</span><a class='hidden_link' href='#thread.lock.shared.mod-1.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,release'><div id='lib:release,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:release,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>mutex_type<span class='operator'>*</span> release<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.mod-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.mod-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8506'>#</a></div><div class='texpara'><div id='thread.lock.shared.mod-2.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>pm <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>nullptr</span></span> and <span class='texttt'>owns <span class='operator'>=</span><span class='operator'>=</span> <span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.shared.mod-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.lock.shared.mod-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.mod-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8510'>#</a></div><div class='texpara'><div id='thread.lock.shared.mod-3.sentence-1' class='sentence'><i >Returns</i>: The previous value of <span class='texttt'>pm</span><a class='hidden_link' href='#thread.lock.shared.mod-3.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,swap_'><div id='lib:swap,shared_lock_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:swap,shared_lock_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Mutex<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>void</span> swap<span class='parenthesis'>(</span>shared_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> x, shared_lock<span class='anglebracket'>&lt;</span>Mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> y<span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.mod-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.mod-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8522'>#</a></div><div class='texpara'><div id='thread.lock.shared.mod-4.sentence-1' class='sentence'><i >Effects</i>: As if by <span class='texttt'>x<span class='operator'>.</span>swap<span class='parenthesis'>(</span>y<span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.shared.mod-4.sentence-1'>.</a></div></div></div></div></div><div id='thread.lock.shared.obs' class='section'><h4 ><a class='secnum' href='#thread.lock.shared.obs' style='min-width:110pt'>32.6.5.5.5</a> Observers <a class='abbr_ref' href='thread.lock.shared.obs'>[thread.lock.shared.obs]</a></h4><div class='texpara'><div id='lib:shared_lock,owns_lock'><div id='lib:owns_lock,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:owns_lock,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>bool</span> owns_lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.obs-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.obs-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8535'>#</a></div><div class='texpara'><div id='thread.lock.shared.obs-1.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>owns</span><a class='hidden_link' href='#thread.lock.shared.obs-1.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,operator_bool'><div id='lib:operator_bool,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:operator_bool,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>explicit</span> <span class='keyword'>operator</span> <span class='keyword'>bool</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.obs-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.obs-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8546'>#</a></div><div class='texpara'><div id='thread.lock.shared.obs-2.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>owns</span><a class='hidden_link' href='#thread.lock.shared.obs-2.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:shared_lock,mutex'><div id='lib:mutex,shared_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:mutex,shared_lock'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>mutex_type<span class='operator'>*</span> mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>const</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='thread.lock.shared.obs-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.shared.obs-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8557'>#</a></div><div class='texpara'><div id='thread.lock.shared.obs-3.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>pm</span><a class='hidden_link' href='#thread.lock.shared.obs-3.sentence-1'>.</a></div></div></div></div></div></div></div><div id='thread.lock.algorithm' class='section'><h3 ><a class='secnum' href='#thread.lock.algorithm' style='min-width:80pt'>32.6.6</a> Generic locking algorithms <a class='abbr_ref' href='thread.lock.algorithm'>[thread.lock.algorithm]</a></h3><div class='texpara'><div id='lib:try_lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:try_lock'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> L1, <span class='keyword'>class</span> L2, <span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> L3<span class='anglebracket'>&gt;</span> <span class="added">constexpr </span><span class='keyword'>int</span> try_lock<span class='parenthesis'>(</span>L1<span class='operator'>&amp;</span>, L2<span class='operator'>&amp;</span>, L3<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.algorithm-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.algorithm-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8570'>#</a></div><div class='texpara'><div id='thread.lock.algorithm-1.sentence-1' class='sentence'><i >Preconditions</i>: Each template parameter type meets the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a> requirements<a class='hidden_link' href='#thread.lock.algorithm-1.sentence-1'>.</a></div> <div id='thread.lock.algorithm-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.lock.algorithm-note-1'>1</a></i>:&ensp;<div id='thread.lock.algorithm-1.sentence-2' class='sentence'>The
<span class='texttt'>unique_<span class='shy'></span>lock</span> class template meets these requirements when suitably instantiated<a class='hidden_link' href='#thread.lock.algorithm-1.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='thread.lock.algorithm-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.algorithm-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8578'>#</a></div><div class='texpara'><div id='thread.lock.algorithm-2.sentence-1' class='sentence'><i >Effects</i>: Calls <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> for each argument in order beginning with the
first until all arguments have been processed or a call to <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> fails,
either by returning <span class='texttt'><span class='literal'>false</span></span> or by throwing an exception<a class='hidden_link' href='#thread.lock.algorithm-2.sentence-1'>.</a></div> <div id='thread.lock.algorithm-2.sentence-2' class='sentence'>If a call to
<span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> fails, <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is called for all prior arguments
with no further calls to <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.algorithm-2.sentence-2'>.</a></div></div></div></div><div class='para' id='thread.lock.algorithm-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.algorithm-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8586'>#</a></div><div class='texpara'><div id='thread.lock.algorithm-3.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'><span class='operator'>-</span><span class='literal'>1</span></span> if all calls to <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returned <span class='texttt'><span class='literal'>true</span></span>,
otherwise a zero-based index value that indicates the argument for which <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
returned <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.lock.algorithm-3.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:lock'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:lock'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> L1, <span class='keyword'>class</span> L2, <span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> L3<span class='anglebracket'>&gt;</span> <span class="added">constexpr </span><span class='keyword'>void</span> lock<span class='parenthesis'>(</span>L1<span class='operator'>&amp;</span>, L2<span class='operator'>&amp;</span>, L3<span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.lock.algorithm-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.algorithm-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8599'>#</a></div><div class='texpara'><div id='thread.lock.algorithm-4.sentence-1' class='sentence'><i >Preconditions</i>: Each template parameter type meets the <a href='thread.req.lockable.req#:Cpp17Lockable' title='32.2.5.3&emsp;Cpp17Lockable requirements&emsp;[thread.req.lockable.req]'><i >Cpp17Lockable</i></a> requirements<a class='hidden_link' href='#thread.lock.algorithm-4.sentence-1'>.</a></div> <div id='thread.lock.algorithm-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.lock.algorithm-note-2'>2</a></i>:&ensp;<div id='thread.lock.algorithm-4.sentence-2' class='sentence'>The
<span class='texttt'>unique_<span class='shy'></span>lock</span> class template meets these requirements when suitably instantiated<a class='hidden_link' href='#thread.lock.algorithm-4.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='thread.lock.algorithm-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.lock.algorithm-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8607'>#</a></div><div class='texpara'><div id='thread.lock.algorithm-5.sentence-1' class='sentence'><i >Effects</i>: All arguments are locked via a sequence of calls to <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
<span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, or <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> on each argument<a class='hidden_link' href='#thread.lock.algorithm-5.sentence-1'>.</a></div> <div id='thread.lock.algorithm-5.sentence-2' class='sentence'>The sequence of calls does
not result in deadlock, but is otherwise unspecified<a class='hidden_link' href='#thread.lock.algorithm-5.sentence-2'>.</a></div> <div id='thread.lock.algorithm-note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.lock.algorithm-note-3'>3</a></i>:&ensp;<div id='thread.lock.algorithm-5.sentence-3' class='sentence'>A deadlock avoidance
algorithm such as try-and-back-off can be used, but the specific algorithm is not
specified to avoid over-constraining implementations<a class='hidden_link' href='#thread.lock.algorithm-5.sentence-3'>.</a></div> —&nbsp;<i>end note</i>]</div></div> <div id='thread.lock.algorithm-5.sentence-4' class='sentence'>
If a call to
<span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> or <span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> throws an exception, <span class='texttt'>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is
called for any argument that had been locked by a call to <span class='texttt'>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> or
<span class='texttt'>try_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span><a class='hidden_link' href='#thread.lock.algorithm-5.sentence-4'>.</a></div></div></div></div></div><div id='thread.once' class='section'><h3 ><a class='secnum' href='#thread.once' style='min-width:80pt'>32.6.7</a> Call once <a class='abbr_ref' href='thread.once'>[thread.once]</a></h3><div id='thread.once.onceflag' class='section'><h4 ><a class='secnum' href='#thread.once.onceflag' style='min-width:95pt'>32.6.7.1</a> Struct <span class='texttt'>once_<span class='shy'></span>flag</span> <a class='abbr_ref' href='thread.once.onceflag'>[thread.once.onceflag]</a></h4><div class='texpara'><span id='lib:once_flag'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:once_flag'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>struct</span> once_flag <span class='curlybracket'>{</span>
    <span class='keyword'>constexpr</span> once_flag<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;

    once_flag<span class='parenthesis'>(</span><span class='keyword'>const</span> once_flag<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    once_flag<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> once_flag<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='thread.once.onceflag-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.onceflag-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8639'>#</a></div><div class='texpara'><div id='thread.once.onceflag-1.sentence-1' class='sentence'>The class <span class='texttt'>once_<span class='shy'></span>flag</span> is an opaque data structure that <span class='texttt'>call_<span class='shy'></span>once</span> uses to
initialize data without causing a data race or deadlock<a class='hidden_link' href='#thread.once.onceflag-1.sentence-1'>.</a></div></div></div><div class='texpara'><div id='lib:once_flag_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:once_flag_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>constexpr</span> once_flag<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div><div class='para' id='thread.once.onceflag-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.onceflag-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8649'>#</a></div><div class='texpara'><div id='thread.once.onceflag-2.sentence-1' class='sentence'><i >Synchronization</i>: The construction of a <span class='texttt'>once_<span class='shy'></span>flag</span> object is not synchronized<a class='hidden_link' href='#thread.once.onceflag-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.once.onceflag-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.onceflag-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8653'>#</a></div><div class='texpara'><div id='thread.once.onceflag-3.sentence-1' class='sentence'><i >Postconditions</i>: The object's internal state is set to indicate to an invocation of
<span class='texttt'>call_<span class='shy'></span>once</span> with the object as its initial argument that no function has been
called<a class='hidden_link' href='#thread.once.onceflag-3.sentence-1'>.</a></div></div></div></div></div><div id='thread.once.callonce' class='section'><h4 ><a class='secnum' href='#thread.once.callonce' style='min-width:95pt'>32.6.7.2</a> Function <span class='texttt'>call_<span class='shy'></span>once</span> <a class='abbr_ref' href='thread.once.callonce'>[thread.once.callonce]</a></h4><div class='texpara'><div id='lib:call_once'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:call_once'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Callable, <span class='keyword'>class</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> Args<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>void</span> call_once<span class='parenthesis'>(</span>once_flag<span class='operator'>&amp;</span> flag, Callable<span class='operator'>&amp;</span><span class='operator'>&amp;</span> func, Args<span class='operator'>&amp;</span><span class='operator'>&amp;</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> args<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='thread.once.callonce-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.callonce-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8669'>#</a></div><div class='texpara'><div id='thread.once.callonce-1.sentence-1' class='sentence'><i >Mandates</i>: <span class='texttt'>is_<span class='shy'></span>invocable_<span class='shy'></span>v<span class='anglebracket'>&lt;</span>Callable, Args<span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='anglebracket'>&gt;</span></span> is <span class='texttt'><span class='literal'>true</span></span><a class='hidden_link' href='#thread.once.callonce-1.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.once.callonce-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.callonce-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8673'>#</a></div><div class='texpara'><div id='thread.once.callonce-2.sentence-1' class='sentence'><i >Effects</i>: An execution of <span class='texttt'>call_<span class='shy'></span>once</span> that does not call its <span class='texttt'>func</span> is a
<a class='hidden_link' href='#def:passive' id='def:passive'><i>passive</i></a> execution<a class='hidden_link' href='#thread.once.callonce-2.sentence-1'>.</a></div> <div id='thread.once.callonce-2.sentence-2' class='sentence'>An execution of <span class='texttt'>call_<span class='shy'></span>once</span> that calls its <span class='texttt'>func</span>
is an <a class='hidden_link' href='#def:active' id='def:active'><i>active</i></a> execution<a class='hidden_link' href='#thread.once.callonce-2.sentence-2'>.</a></div> <div id='thread.once.callonce-2.sentence-3' class='sentence'>An active execution evaluates
<span class='texttt'><i >INVOKE</i><span class='parenthesis'>(</span>&#x200b;std<span class='operator'>&#x200b;::&#x200b;</span>forward<span class='anglebracket'>&lt;</span>Callable<span class='anglebracket'>&gt;</span><span class='parenthesis'>(</span>func<span class='parenthesis'>)</span>,
std<span class='operator'>&#x200b;::&#x200b;</span>forward<span class='anglebracket'>&lt;</span>Args<span class='anglebracket'>&gt;</span><span class='parenthesis'>(</span>args<span class='parenthesis'>)</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='parenthesis'>)</span></span> (<a href='func.require' title='22.10.4&emsp;Requirements'>[func.<span class='shy'></span>require]</a>)<a class='hidden_link' href='#thread.once.callonce-2.sentence-3'>.</a></div> <div id='thread.once.callonce-2.sentence-4' class='sentence'>If such a call to <span class='texttt'>func</span>
throws an exception the execution is <a class='hidden_link' href='#def:exceptional' id='def:exceptional'><i>exceptional</i></a>, otherwise it is <a class='hidden_link' href='#def:returning' id='def:returning'><i>returning</i></a><a class='hidden_link' href='#thread.once.callonce-2.sentence-4'>.</a></div> <div id='thread.once.callonce-2.sentence-5' class='sentence'>An exceptional execution propagates the exception to the caller of
<span class='texttt'>call_<span class='shy'></span>once</span><a class='hidden_link' href='#thread.once.callonce-2.sentence-5'>.</a></div> <div id='thread.once.callonce-2.sentence-6' class='sentence'>Among all executions of <span class='texttt'>call_<span class='shy'></span>once</span> for any given
<span class='texttt'>once_<span class='shy'></span>flag</span>: at most one is a returning execution; if there is a
returning execution, it is the last active execution; and there are
passive executions only if there is a returning execution<a class='hidden_link' href='#thread.once.callonce-2.sentence-6'>.</a></div> <div id='thread.once.callonce-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.once.callonce-note-1'>1</a></i>:&ensp;<div id='thread.once.callonce-2.sentence-7' class='sentence'>Passive
executions allow other threads to reliably observe the results produced by the
earlier returning execution<a class='hidden_link' href='#thread.once.callonce-2.sentence-7'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='thread.once.callonce-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.callonce-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8693'>#</a></div><div class='texpara'><div id='thread.once.callonce-3.sentence-1' class='sentence'><i >Synchronization</i>: For any given <span class='texttt'>once_<span class='shy'></span>flag</span>: all active executions occur in a total
order; completion of an active execution <a href='intro.multithread#def:synchronize_with' title='6.9.2&emsp;Multi-threaded executions and data races&emsp;[intro.multithread]'>synchronizes with</a>
the start of the next one in this total order; and the returning execution
synchronizes with the return from all passive executions<a class='hidden_link' href='#thread.once.callonce-3.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.once.callonce-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.callonce-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8700'>#</a></div><div class='texpara'><div id='thread.once.callonce-4.sentence-1' class='sentence'><i >Throws</i>: <span class='texttt'>system_<span class='shy'></span>error</span> when
an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>), or any exception thrown by <span class='texttt'>func</span><a class='hidden_link' href='#thread.once.callonce-4.sentence-1'>.</a></div></div></div></div><div class='para nonNormativeOnly' id='thread.once.callonce-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.once.callonce-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8705'>#</a></div><div class='texpara'><div id='thread.once.callonce-example-1' class='example'><div class='texpara'>[<i>Example&nbsp;<a href='#thread.once.callonce-example-1'>1</a></i>:&ensp;<span class='codeblock'><span class='comment'>// global flag, regular function</span>
<span class='keyword'>void</span> init<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
std<span class='operator'>::</span>once_flag flag;

<span class='keyword'>void</span> f<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  std<span class='operator'>::</span>call_once<span class='parenthesis'>(</span>flag, init<span class='parenthesis'>)</span>;
<span class='curlybracket'>}</span>

<span class='comment'>// function static flag, function object</span>
<span class='keyword'>struct</span> initializer <span class='curlybracket'>{</span>
  <span class='keyword'>void</span> <span class='keyword'>operator</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
<span class='curlybracket'>}</span>;

<span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  <span class='keyword'>static</span> std<span class='operator'>::</span>once_flag flag2;
  std<span class='operator'>::</span>call_once<span class='parenthesis'>(</span>flag2, initializer<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>;
<span class='curlybracket'>}</span>

<span class='comment'>// object flag, member function</span>
<span class='keyword'>class</span> information <span class='curlybracket'>{</span>
  std<span class='operator'>::</span>once_flag verified;
  <span class='keyword'>void</span> verifier<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
<span class='keyword'>public</span><span class='operator'>:</span>
  <span class='keyword'>void</span> verify<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> std<span class='operator'>::</span>call_once<span class='parenthesis'>(</span>verified, <span class='operator'>&amp;</span>information<span class='operator'>::</span>verifier, <span class='operator'>*</span><span class='keyword'>this</span><span class='parenthesis'>)</span>; <span class='curlybracket'>}</span>
<span class='curlybracket'>}</span>;
</span> —&nbsp;<i>end example</i>]</div></div></div></div></div></div></div>
</div>
</section><section data-related="timing-specifications"><h3><a href="#timing-specifications" id="timing-specifications">Timing specifications</a></h3>
<!-- thread.req.timing.html (wording) -->
<div class="wording">
<h3 ><a class='secnum' style='min-width:80pt'>32.2.4</a> Timing specifications <a class='abbr_ref'>[thread.req.timing]</a></h3>

<div class='para' id='1'><div class='marginalizedparent'><a class='marginalized' href='#1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L90'>#</a></div><div class='texpara'><div id='1.sentence-1' class='sentence'>Several functions described in this Clause take an argument to specify a timeout<a class='hidden_link' href='#1.sentence-1'>.</a></div> <div id='1.sentence-2' class='sentence'>These
timeouts are specified as either a <span class='texttt'>duration</span> or a <span class='texttt'>time_<span class='shy'></span>point</span> type as
specified in <a href='time' title='30&emsp;Time library'>[time]</a><a class='hidden_link' href='#1.sentence-2'>.</a></div></div></div>

<div class='para' id='2'><div class='marginalizedparent'><a class='marginalized' href='#2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L95'>#</a></div><div class='texpara'><div id='2.sentence-1' class='sentence'>Implementations necessarily have some delay in returning from a timeout<a class='hidden_link' href='#2.sentence-1'>.</a></div> <div id='2.sentence-2' class='sentence'>Any overhead in
interrupt response, function return, and scheduling induces a “quality of implementation”
delay, expressed as duration <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span></span><a class='hidden_link' href='#2.sentence-2'>.</a></div> <div id='2.sentence-3' class='sentence'>Ideally, this delay would be zero<a class='hidden_link' href='#2.sentence-3'>.</a></div> <div id='2.sentence-4' class='sentence'>Further, any contention for
processor and memory resources induces a “quality of management” delay, expressed as duration
<span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">m</span></span></span></span></span></span></span></span><a class='hidden_link' href='#2.sentence-4'>.</a></div> <div id='2.sentence-5' class='sentence'>The delay durations may vary from timeout to timeout, but in all cases shorter is better<a class='hidden_link' href='#2.sentence-5'>.</a></div></div></div>

<div class='para' id='3'><div class='marginalizedparent'><a class='marginalized' href='#3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L102'>#</a></div><div class='texpara'><div id='3.sentence-1' class='sentence'>The functions whose names end in <span class='texttt'>_<span class='shy'></span>for</span> take an argument that
specifies a duration<a class='hidden_link' href='#3.sentence-1'>.</a></div> <div id='3.sentence-2' class='sentence'>These functions produce relative timeouts<a class='hidden_link' href='#3.sentence-2'>.</a></div> <div id='3.sentence-3' class='sentence'>Implementations
should use a steady clock to measure time for these functions<a class='hidden_link' href='#3.sentence-3'>.</a><a class='footnoteref' href='#footnote-294' id='footnoteref-294' title='Implementations for which standard time units are meaningful will typically have a steady clock within their hardware implementation.'>294</a></div> <div id='3.sentence-4' class='sentence'>
Given a duration
argument <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span>, the real-time duration of the timeout is <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">m</span></span></span></span></span></span></span></span><a class='hidden_link' href='#3.sentence-4'>.</a></div></div></div>

<div class='para' id='4'><div class='marginalizedparent'><a class='marginalized' href='#4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L113'>#</a></div><div class='texpara'><div id='4.sentence-1' class='sentence'>The functions whose names end in <span class='texttt'>_<span class='shy'></span>until</span> take an argument that specifies a time
point<a class='hidden_link' href='#4.sentence-1'>.</a></div> <div id='4.sentence-2' class='sentence'>These functions produce absolute timeouts<a class='hidden_link' href='#4.sentence-2'>.</a></div> <div id='4.sentence-3' class='sentence'>Implementations should use the clock
specified in the time point to measure time for these functions<a class='hidden_link' href='#4.sentence-3'>.</a></div> <div id='4.sentence-4' class='sentence'>Given a clock time point
argument <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span>, the clock time point of the return from timeout should be <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">m</span></span></span></span></span></span></span></span>
when the clock is not adjusted during the timeout<a class='hidden_link' href='#4.sentence-4'>.</a></div> <div id='4.sentence-5' class='sentence'>If the clock is adjusted to the time <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">a</span></span></span></span></span></span></span></span>
during the timeout, the behavior should be as follows:
<ul class='itemize'><li id='4.1'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#4.1'>(4.1)</a></div><div class='texpara'><div id='4.1.sentence-1' class='sentence'>If <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">a</span></span></span></span><span class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.225em; padding-bottom: 0.372em;">&gt;</span></span><span class="mjx-msubsup MJXc-space3"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span>, the waiting function should wake as soon as possible, i.e., <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">a</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">m</span></span></span></span></span></span></span></span>,
since the timeout is already satisfied<a class='hidden_link' href='#4.1.sentence-1'>.</a></div> <div id='4.1.sentence-2' class='sentence'>This specification may result in the total
duration of the wait decreasing when measured against a steady clock<a class='hidden_link' href='#4.1.sentence-2'>.</a></div></div></li><li id='4.2'><div class='marginalizedparent' style='left:-27mm'><a class='marginalized' href='#4.2'>(4.2)</a></div><div class='texpara'><div id='4.2.sentence-1' class='sentence'>If <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">a</span></span></span></span><span class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.446em;">≤</span></span><span class="mjx-texatom MJXc-space3"><span class="mjx-mrow"></span></span><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span>, the waiting function should not time out until <span class='texttt'>Clock<span class='operator'>&#x200b;::&#x200b;</span>now<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns a
time <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">n</span></span></span></span><span class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.446em;">≥</span></span><span class="mjx-texatom MJXc-space3"><span class="mjx-mrow"></span></span><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span>, i.e., waking at <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span><span class="mjx-mo MJXc-space2"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.298em; padding-bottom: 0.446em;">+</span></span><span class="mjx-msubsup MJXc-space2"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">D</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">m</span></span></span></span></span></span></span></span><a class='hidden_link' href='#4.2.sentence-1'>.</a></div> <div id='note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#note-1'>1</a></i>:&ensp;<div id='4.2.sentence-2' class='sentence'>When the clock is adjusted
backwards, this specification can result in the total duration of the wait increasing when
measured against a steady clock<a class='hidden_link' href='#4.2.sentence-2'>.</a></div> <div id='4.2.sentence-3' class='sentence'>When the clock is adjusted forwards, this specification can
result in the total duration of the wait decreasing when measured against a steady clock<a class='hidden_link' href='#4.2.sentence-3'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></li></ul></div></div><div class='texpara'><div id='4.sentence-6' class='sentence'>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 <span class='math'><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base" style="margin-right: -0.045em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em; padding-right: 0.045em;">C</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span>
and the time point of the call to the <span class='texttt'>_<span class='shy'></span>until</span> function<a class='hidden_link' href='#4.sentence-6'>.</a></div></div><div class='texpara'><div id='4.sentence-7' class='sentence'><i >Recommended practice</i>: Implementations
should decrease the duration of the wait when the clock is adjusted forwards<a class='hidden_link' href='#4.sentence-7'>.</a></div></div></div><div class='para nonNormativeOnly' id='5'><div class='marginalizedparent'><a class='marginalized' href='#5'>5</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L146'>#</a></div><div class='texpara'><div id='note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#note-2'>2</a></i>:&ensp;<div id='5.sentence-1' class='sentence'>If the clock is not synchronized with a steady clock, e.g., a CPU time clock, these
timeouts can fail to provide useful functionality<a class='hidden_link' href='#5.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div>

<div class='para' id='6'><div class='marginalizedparent'><a class='marginalized' href='#6'>6</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L152'>#</a></div><div class='texpara'><div id='6.sentence-1' class='sentence'>The resolution of timing provided by an implementation depends on both operating system
and hardware<a class='hidden_link' href='#6.sentence-1'>.</a></div> <div id='6.sentence-2' class='sentence'>The finest resolution provided by an implementation is called the
<a class='hidden_link' href='#def:native_resolution' id='def:native_resolution'><i>native resolution</i></a><a class='hidden_link' href='#6.sentence-2'>.</a></div></div></div>

<div class='para' id='7'><div class='marginalizedparent'><a class='marginalized' href='#7'>7</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L157'>#</a></div><div class='texpara'><div id='7.sentence-1' class='sentence'>Implementation-provided clocks that are used for these functions meet the
<a href='time.clock.req#:Cpp17TrivialClock' title='30.3&emsp;Cpp17Clock requirements&emsp;[time.clock.req]'><i >Cpp17TrivialClock</i></a> requirements (<a href='time.clock.req' title='30.3&emsp;Cpp17Clock requirements'>[time.<span class='shy'></span>clock.<span class='shy'></span>req]</a>)<a class='hidden_link' href='#7.sentence-1'>.</a></div></div></div>

<div class='para' id='8'><div class='marginalizedparent'><a class='marginalized' href='#8'>8</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L161'>#</a></div><div class='texpara'><div id='8.sentence-1' class='sentence'>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<a class='hidden_link' href='#8.sentence-1'>.</a></div> <div id='8.sentence-2' class='sentence'>Such exceptions are referred to as <a class='hidden_link' href='#def:timeout-related_exceptions' id='def:timeout-related_exceptions'><i>timeout-related exceptions</i></a><a class='hidden_link' href='#8.sentence-2'>.</a></div> <div id='note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#note-3'>3</a></i>:&ensp;<div id='8.sentence-3' class='sentence'>Instantiations of clock, time point and duration types supplied by
the implementation as specified in <a href='time.clock' title='30.7&emsp;Clocks'>[time.<span class='shy'></span>clock]</a> do not throw exceptions<a class='hidden_link' href='#8.sentence-3'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div><div class='footnoteSeparator'></div><div class='footnote' id='footnote-294'><div class='texpara'><a class='footnotenum' href='#footnote-294'>294)</a><a class='footnoteBacklink' href='#footnoteref-294'>294)</a> <div id='footnote-294.sentence-1' class='sentence'>Implementations for which standard time units are meaningful will typically
have a steady clock within their hardware implementation<a class='hidden_link' href='#footnote-294.sentence-1'>.</a></div></div></div>

<div class='para' id='wording-change-for-timed-in-constant-evaluation'><div class="added"><div class='marginalizedparent'><a class='marginalized' href='#wording-change-for-timed-in-constant-evaluation'>?</a></div><div class='sourceLinkParent'></div><div class='texpara'><div id='9.sentence-1' class='sentence'>During constant evaluation [expr.const] all functions taking timeout argument will return immediately as if the time requested already passed.</div></div></div></div>
</div>
</section><section data-related="condition-variables"><h3><a href="#condition-variables" id="condition-variables">Condition variables</a></h3>
<!-- thread.condition.html (wording) -->
<div class="wording">
<h2 ><a class='secnum' style='min-width:65pt'>32.7</a> Condition variables <a class='abbr_ref'>[thread.condition]</a></h2><div id='general' class='section'><h3 ><a class='secnum' href='#general' style='min-width:80pt'>32.7.1</a> General <a class='abbr_ref' href='thread.condition.general'>[thread.condition.general]</a></h3><div class='para' id='general-1'><div class='marginalizedparent'><a class='marginalized' href='#general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8742'>#</a></div><div class='texpara'><div id='general-1.sentence-1' class='sentence'>Condition variables provide synchronization primitives used to block a thread until
notified by some other thread that some condition is met or until a system time is
reached<a class='hidden_link' href='#general-1.sentence-1'>.</a></div> <div id='general-1.sentence-2' class='sentence'>Class <span class='texttt'>condition_<span class='shy'></span>variable</span> provides a condition variable that can only
wait on an object of type <span class='texttt'>unique_<span class='shy'></span>lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span></span>, allowing the implementation
to be more efficient<a class='hidden_link' href='#general-1.sentence-2'>.</a></div> <div id='general-1.sentence-3' class='sentence'>Class <span class='texttt'>condition_<span class='shy'></span>variable_<span class='shy'></span>any</span> provides a general
condition variable that can wait on objects of user-supplied lock types<a class='hidden_link' href='#general-1.sentence-3'>.</a></div></div></div><div class='para' id='general-2'><div class='marginalizedparent'><a class='marginalized' href='#general-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8750'>#</a></div><div class='texpara'><div id='general-2.sentence-1' class='sentence'>Condition variables permit concurrent invocation of the <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>,
<span class='texttt'>wait_<span class='shy'></span>until</span>, <span class='texttt'>notify_<span class='shy'></span>one</span> and <span class='texttt'>notify_<span class='shy'></span>all</span> member functions<a class='hidden_link' href='#general-2.sentence-1'>.</a></div></div></div><div class='para' id='general-3'><div class='marginalizedparent'><a class='marginalized' href='#general-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8754'>#</a></div><div class='texpara'><div id='general-3.sentence-1' class='sentence'>The executions of <span class='texttt'>notify_<span class='shy'></span>one</span> and <span class='texttt'>notify_<span class='shy'></span>all</span>
are atomic<a class='hidden_link' href='#general-3.sentence-1'>.</a></div> <div id='general-3.sentence-2' class='sentence'>The executions of <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>, and <span class='texttt'>wait_<span class='shy'></span>until</span> are performed
in three atomic parts:
<table class='enumerate'><tr id='general-3.1'><td ><a class='enumerated_item_num' href='#general-3.1'>1.</a></td><td >the release of the mutex and entry into the waiting state;</td></tr><tr id='general-3.2'><td ><a class='enumerated_item_num' href='#general-3.2'>2.</a></td><td >the unblocking of the wait; and</td></tr><tr id='general-3.3'><td ><a class='enumerated_item_num' href='#general-3.3'>3.</a></td><td >the reacquisition of the lock<a class='hidden_link' href='#general-3.sentence-2'>.</a></td></tr></table></div></div></div><div class='para' id='general-4'><div class='marginalizedparent'><a class='marginalized' href='#general-4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8765'>#</a></div><div class='texpara'><div id='general-4.sentence-1' class='sentence'>The implementation behaves as if all executions of <span class='texttt'>notify_<span class='shy'></span>one</span>, <span class='texttt'>notify_<span class='shy'></span>all</span>, and each
part of the <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>, and <span class='texttt'>wait_<span class='shy'></span>until</span> executions are
executed in a single unspecified total order consistent with the “happens before” order<a class='hidden_link' href='#general-4.sentence-1'>.</a></div></div></div><div class='para' id='general-5'><div class='marginalizedparent'><a class='marginalized' href='#general-5'>5</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8770'>#</a></div><div class='texpara'><div id='general-5.sentence-1' class='sentence'>Condition variable construction and destruction need not be synchronized<a class='hidden_link' href='#general-5.sentence-1'>.</a></div></div></div></div><div id='condition.variable.syn' class='section'><h3 ><a class='secnum' href='#condition.variable.syn' style='min-width:80pt'>32.7.2</a> Header <span class='texttt'>&lt;condition_<span class='shy'></span>variable&gt;</span> synopsis <a class='abbr_ref' href='condition.variable.syn'>[condition.variable.syn]</a></h3><div class='texpara'><span id='header:<condition_variable>'><div class='marginalizedparent'><a class='itemDeclLink' href='#header:%3ccondition_variable%3e'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='comment'>// <a href='#condvar' title='32.7.4&emsp;Class condition_&shy;variable'>[thread.<span class='shy'></span>condition.<span class='shy'></span>condvar]</a>, class <span class='tcode_in_codeblock'>condition_<span class='shy'></span>variable</span></span>
  <span class='keyword'>class</span> condition_variable;
  <span class='comment'>// <a href='#condvarany' title='32.7.5&emsp;Class condition_&shy;variable_&shy;any'>[thread.<span class='shy'></span>condition.<span class='shy'></span>condvarany]</a>, class <span class='tcode_in_codeblock'>condition_<span class='shy'></span>variable_<span class='shy'></span>any</span></span>
  <span class='keyword'>class</span> condition_variable_any;

  <span class='comment'>// <a href='#nonmember' title='32.7.3&emsp;Non-member functions'>[thread.<span class='shy'></span>condition.<span class='shy'></span>nonmember]</a>, non-member functions</span>
  <span class="added">constexpr </span><span class='keyword'>void</span> notify_all_at_thread_exit<span class='parenthesis'>(</span>condition_variable<span class='operator'>&amp;</span> cond, unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span> lk<span class='parenthesis'>)</span>;

  <span class='keyword'>enum</span> <span class='keyword'>class</span> <span id='lib:cv_status'><a class='hidden_link' href='#lib:cv_status' title='32.7.2&emsp;Header &lt;condition_&shy;variable&gt; synopsis&emsp;[condition.variable.syn]'>cv_status</a></span> <span class='curlybracket'>{</span> <span id='lib:cv_status,no_timeout'><span id='lib:no_timeout,cv_status'><a class='hidden_link' href='#lib:cv_status,no_timeout' title='32.7.2&emsp;Header &lt;condition_&shy;variable&gt; synopsis&emsp;[condition.variable.syn]'>no_timeout</a></span></span>, <span id='lib:cv_status,timeout'><span id='lib:timeout,cv_status'><a class='hidden_link' href='#lib:cv_status,timeout' title='32.7.2&emsp;Header &lt;condition_&shy;variable&gt; synopsis&emsp;[condition.variable.syn]'>timeout</a></span></span> <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div></div><div id='nonmember' class='section'><h3 ><a class='secnum' href='#nonmember' style='min-width:80pt'>32.7.3</a> Non-member functions <a class='abbr_ref' href='thread.condition.nonmember'>[thread.condition.nonmember]</a></h3><div class='texpara'><div id='lib:notify_all_at_thread_exit'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:notify_all_at_thread_exit'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> notify_all_at_thread_exit<span class='parenthesis'>(</span>condition_variable<span class='operator'>&amp;</span> cond, unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span> lk<span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='nonmember-1'><div class='marginalizedparent'><a class='marginalized' href='#nonmember-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8797'>#</a></div><div class='texpara'><div id='nonmember-1.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>lk</span> is locked by the calling thread and either
<ul class='itemize'><li id='nonmember-1.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#nonmember-1.1'>(1.1)</a></div>no other thread is waiting on <span class='texttt'>cond</span>, or</li><li id='nonmember-1.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#nonmember-1.2'>(1.2)</a></div><span class='texttt'>lk<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns the same value for each of the lock arguments
supplied by all concurrently waiting (via <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>,
or <span class='texttt'>wait_<span class='shy'></span>until</span>) threads<a class='hidden_link' href='#nonmember-1.sentence-1'>.</a></li></ul></div></div></div></div><div class='para' id='nonmember-2'><div class='marginalizedparent'><a class='marginalized' href='#nonmember-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8807'>#</a></div><div class='texpara'><div id='nonmember-2.sentence-1' class='sentence'><i >Effects</i>: Transfers ownership of the lock associated with <span class='texttt'>lk</span> into
internal storage and schedules <span class='texttt'>cond</span> to be notified when the current
thread exits, after all objects with thread storage duration associated with
the current thread have been destroyed<a class='hidden_link' href='#nonmember-2.sentence-1'>.</a></div> <div id='nonmember-2.sentence-2' class='sentence'>This notification is equivalent to:
<span class='codeblock'>lk<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
cond<span class='operator'>.</span>notify_all<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='para' id='nonmember-3'><div class='marginalizedparent'><a class='marginalized' href='#nonmember-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8818'>#</a></div><div class='texpara'><div id='nonmember-3.sentence-1' class='sentence'><i >Synchronization</i>: The implied <span class='texttt'>lk<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> call is sequenced after the destruction of
all objects with thread storage duration associated with the current thread<a class='hidden_link' href='#nonmember-3.sentence-1'>.</a></div></div>

<div id='notify_all_at_thread_exit-note' class='note'>
<div class='texpara added'>[<i>Note&nbsp;<a href='#notify_all_at_thread_exit-note'>?</a></i>:&ensp;<div class='sentence'>There is only one thread during constant evaluation and using this in such environment is a no-op.</div> —&nbsp;<i>end note</i>]</div>
</div>

</div></div><div class='para nonNormativeOnly' id='nonmember-4'><div class='marginalizedparent'><a class='marginalized' href='#nonmember-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8823'>#</a></div><div class='texpara'><div id='nonmember-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#nonmember-note-1'>1</a></i>:&ensp;<div id='nonmember-4.sentence-1' class='sentence'>The supplied lock is held until the thread exits,
which might cause deadlock due to lock ordering issues<a class='hidden_link' href='#nonmember-4.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para nonNormativeOnly' id='nonmember-5'><div class='marginalizedparent'><a class='marginalized' href='#nonmember-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8829'>#</a></div><div class='texpara'><div id='nonmember-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#nonmember-note-2'>2</a></i>:&ensp;<div id='nonmember-5.sentence-1' class='sentence'>It is the user's responsibility to ensure that waiting threads
do not incorrectly assume that the thread has finished if they experience
spurious wakeups<a class='hidden_link' href='#nonmember-5.sentence-1'>.</a></div> <div id='nonmember-5.sentence-2' class='sentence'>This typically requires that the condition being waited
for is satisfied while holding the lock on <span class='texttt'>lk</span>, and that this lock
is not released and reacquired prior to calling <span class='texttt'>notify_<span class='shy'></span>all_<span class='shy'></span>at_<span class='shy'></span>thread_<span class='shy'></span>exit</span><a class='hidden_link' href='#nonmember-5.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div></div><div id='condvar' class='section'><h3 ><a class='secnum' href='#condvar' style='min-width:80pt'>32.7.4</a> Class <span class='texttt'>condition_<span class='shy'></span>variable</span> <a class='abbr_ref' href='thread.condition.condvar'>[thread.condition.condvar]</a></h3><div class='texpara'><span id='lib:condition_variable'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:condition_variable'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> condition_variable <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class="added">constexpr </span>condition_variable<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>condition_variable<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    condition_variable<span class='parenthesis'>(</span><span class='keyword'>const</span> condition_variable<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    condition_variable<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> condition_variable<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span><span class='keyword'>void</span> notify_one<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> notify_all<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock, Predicate pred<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>cv_status wait_until<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                           <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> wait_until<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                      <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time,
                      Predicate pred<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>cv_status wait_for<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                         <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> wait_for<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                    <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time,
                    Predicate pred<span class='parenthesis'>)</span>;

    <span class='keyword'>using</span> native_handle_type <span class='operator'>=</span> <i >implementation-defined</i>;          <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
    native_handle_type native_handle<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                         <span class='comment'>// see <a href='thread.req.native' title='32.2.3&emsp;Native handles'>[thread.<span class='shy'></span>req.<span class='shy'></span>native]</a></span>
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='condvar-1'><div class='marginalizedparent'><a class='marginalized' href='#condvar-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8878'>#</a></div><div class='texpara'><div id='condvar-1.sentence-1' class='sentence'>The class <span class='texttt'>condition_<span class='shy'></span>variable</span> is a standard-layout class (<a href='class.prop' title='11.2&emsp;Properties of classes'>[class.<span class='shy'></span>prop]</a>)<a class='hidden_link' href='#condvar-1.sentence-1'>.</a></div></div></div><div class='texpara'><div id='lib:condition_variable,constructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:condition_variable,constructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>condition_variable<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='condvar-2'><div class='marginalizedparent'><a class='marginalized' href='#condvar-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8887'>#</a></div><div class='texpara'><div id='condvar-2.sentence-1' class='sentence'><i >Throws</i>: <span class='texttt'>system_<span class='shy'></span>error</span> when an exception is required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#condvar-2.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-3'><div class='marginalizedparent'><a class='marginalized' href='#condvar-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8891'>#</a></div><div class='texpara'><div id='condvar-3.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='condvar-3.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-3.1'>(3.1)</a></div><span class='texttt'>resource_<span class='shy'></span>unavailable_<span class='shy'></span>try_<span class='shy'></span>again</span> — if some non-memory resource
limitation prevents initialization<a class='hidden_link' href='#condvar-3.sentence-1'>.</a></li></ul></div></div></div></div><div class='texpara'><div id='lib:condition_variable,destructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:condition_variable,destructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='operator'>~</span>condition_variable<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='condvar-4'><div class='marginalizedparent'><a class='marginalized' href='#condvar-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8905'>#</a></div><div class='texpara'><div id='condvar-4.sentence-1' class='sentence'><i >Preconditions</i>: There is no thread blocked on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#condvar-4.sentence-1'>.</a></div> <div id='condvar-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-1'>1</a></i>:&ensp;<div id='condvar-4.sentence-2' class='sentence'>That is, all
threads have been notified; they can subsequently block on the lock specified in the
wait<a class='hidden_link' href='#condvar-4.sentence-2'>.</a></div> <div id='condvar-4.sentence-3' class='sentence'>This relaxes the usual rules, which would have required all wait calls to happen before
destruction<a class='hidden_link' href='#condvar-4.sentence-3'>.</a></div> <div id='condvar-4.sentence-4' class='sentence'>Only the notification to unblock the wait needs to happen before destruction<a class='hidden_link' href='#condvar-4.sentence-4'>.</a></div> <div id='condvar-4.sentence-5' class='sentence'>Undefined behavior ensues if a thread waits on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span> once the destructor has
been started, especially when the waiting threads are calling the wait functions in a loop or
using the overloads of <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>, or <span class='texttt'>wait_<span class='shy'></span>until</span> that take a predicate<a class='hidden_link' href='#condvar-4.sentence-5'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable,notify_one'><div id='lib:notify_one,condition_variable'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:notify_one,condition_variable'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> notify_one<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='condvar-5'><div class='marginalizedparent'><a class='marginalized' href='#condvar-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8926'>#</a></div><div class='texpara'><div id='condvar-5.sentence-1' class='sentence'><i >Effects</i>: If any threads are blocked waiting for <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span>, unblocks one of those threads<a class='hidden_link' href='#condvar-5.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:condition_variable,notify_all'><div id='lib:notify_all,condition_variable'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:notify_all,condition_variable'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> notify_all<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='condvar-6'><div class='marginalizedparent'><a class='marginalized' href='#condvar-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8937'>#</a></div><div class='texpara'><div id='condvar-6.sentence-1' class='sentence'><i >Effects</i>: Unblocks all threads that are blocked waiting for <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#condvar-6.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:condition_variable,wait'><div id='lib:wait,condition_variable'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait,condition_variable'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='condvar-7'><div class='marginalizedparent'><a class='marginalized' href='#condvar-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8948'>#</a></div><div class='texpara'><div id='condvar-7.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread, and either
<ul class='itemize'><li id='condvar-7.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-7.1'>(7.1)</a></div>no other thread is waiting on this <span class='texttt'>condition_<span class='shy'></span>variable</span> object or</li><li id='condvar-7.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-7.2'>(7.2)</a></div><span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns the same value for each of the <span class='texttt'>lock</span>
arguments supplied by all concurrently waiting (via <span class='texttt'>wait</span>,
<span class='texttt'>wait_<span class='shy'></span>for</span>, or <span class='texttt'>wait_<span class='shy'></span>until</span>) threads<a class='hidden_link' href='#condvar-7.sentence-1'>.</a></li></ul></div></div></div></div><div class='para' id='condvar-8'><div class='marginalizedparent'><a class='marginalized' href='#condvar-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8959'>#</a></div><div class='texpara'><div id='condvar-8.sentence-1' class='sentence'><a class='index' id=':block_(execution)'></a><i >Effects</i>: <ul class='itemize'><li id='condvar-8.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-8.1'>(8.1)</a></div><div class='texpara'><div id='condvar-8.1.sentence-1' class='sentence'>Atomically calls <span class='texttt'>lock<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> and blocks on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#condvar-8.1.sentence-1'>.</a></div></div></li><li id='condvar-8.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-8.2'>(8.2)</a></div><div class='texpara'><div id='condvar-8.2.sentence-1' class='sentence'>When unblocked, calls <span class='texttt'>lock<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> (possibly blocking on the lock), then returns<a class='hidden_link' href='#condvar-8.2.sentence-1'>.</a></div></div></li><li id='condvar-8.3'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-8.3'>(8.3)</a></div><div class='texpara'><div id='condvar-8.3.sentence-1' class='sentence'>The function will unblock when signaled by a call to <span class='texttt'>notify_<span class='shy'></span>one<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
or a call to <span class='texttt'>notify_<span class='shy'></span>all<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, or spuriously<a class='hidden_link' href='#condvar-8.3.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='para' id='condvar-9'><div class='marginalizedparent'><a class='marginalized' href='#condvar-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8969'>#</a></div><div class='texpara'><div id='condvar-9.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread<a class='hidden_link' href='#condvar-9.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-10'><div class='marginalizedparent'><a class='marginalized' href='#condvar-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8974'>#</a></div><div class='texpara'><div id='condvar-10.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#condvar-10.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-11'><div class='marginalizedparent'><a class='marginalized' href='#condvar-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8978'>#</a></div><div class='texpara'><div id='condvar-11.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#condvar-11.sentence-1'>.</a></div> <div id='condvar-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-2'>2</a></i>:&ensp;<div id='condvar-11.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#condvar-11.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable,wait_'><div id='lib:wait,condition_variable_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait,condition_variable_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock, Predicate pred<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='condvar-12'><div class='marginalizedparent'><a class='marginalized' href='#condvar-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L8994'>#</a></div><div class='texpara'><div id='condvar-12.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is
locked by the calling thread, and either
<ul class='itemize'><li id='condvar-12.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-12.1'>(12.1)</a></div>no other thread is waiting on this <span class='texttt'>condition_<span class='shy'></span>variable</span> object or</li><li id='condvar-12.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-12.2'>(12.2)</a></div><span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns the same value for each of the <span class='texttt'>lock</span>
arguments supplied by all concurrently waiting (via <span class='texttt'>wait</span>,
<span class='texttt'>wait_<span class='shy'></span>for</span>, or <span class='texttt'>wait_<span class='shy'></span>until</span>) threads<a class='hidden_link' href='#condvar-12.sentence-1'>.</a></li></ul></div></div></div></div><div class='para' id='condvar-13'><div class='marginalizedparent'><a class='marginalized' href='#condvar-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9005'>#</a></div><div class='texpara'><div id='condvar-13.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>while</span> <span class='parenthesis'>(</span><span class='operator'>!</span>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
  wait<span class='parenthesis'>(</span>lock<span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='para' id='condvar-14'><div class='marginalizedparent'><a class='marginalized' href='#condvar-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9013'>#</a></div><div class='texpara'><div id='condvar-14.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread<a class='hidden_link' href='#condvar-14.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-15'><div class='marginalizedparent'><a class='marginalized' href='#condvar-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9018'>#</a></div><div class='texpara'><div id='condvar-15.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pred</span><a class='hidden_link' href='#condvar-15.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-16'><div class='marginalizedparent'><a class='marginalized' href='#condvar-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9022'>#</a></div><div class='texpara'><div id='condvar-16.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#condvar-16.sentence-1'>.</a></div> <div id='condvar-note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-3'>3</a></i>:&ensp;<div id='condvar-16.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#condvar-16.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable,wait_until'><div id='lib:wait_until,condition_variable'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_until,condition_variable'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>cv_status wait_until<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                       <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='condvar-17'><div class='marginalizedparent'><a class='marginalized' href='#condvar-17'>17</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9039'>#</a></div><div class='texpara'><div id='condvar-17.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread, and either
<ul class='itemize'><li id='condvar-17.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-17.1'>(17.1)</a></div>no other thread is waiting on this <span class='texttt'>condition_<span class='shy'></span>variable</span> object or</li><li id='condvar-17.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-17.2'>(17.2)</a></div><span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns the same value for each of the <span class='texttt'>lock</span>
arguments supplied by all concurrently waiting (via <span class='texttt'>wait</span>,
<span class='texttt'>wait_<span class='shy'></span>for</span>, or <span class='texttt'>wait_<span class='shy'></span>until</span>) threads<a class='hidden_link' href='#condvar-17.sentence-1'>.</a></li></ul></div></div></div></div><div class='para' id='condvar-18'><div class='marginalizedparent'><a class='marginalized' href='#condvar-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9050'>#</a></div><div class='texpara'><div id='condvar-18.sentence-1' class='sentence'><i >Effects</i>: <ul class='itemize'><li id='condvar-18.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-18.1'>(18.1)</a></div><div class='texpara'><div id='condvar-18.1.sentence-1' class='sentence'>Atomically calls <span class='texttt'>lock<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> and blocks on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#condvar-18.1.sentence-1'>.</a></div></div></li><li id='condvar-18.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-18.2'>(18.2)</a></div><div class='texpara'><div id='condvar-18.2.sentence-1' class='sentence'>When unblocked, calls <span class='texttt'>lock<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> (possibly blocking on the lock), then returns<a class='hidden_link' href='#condvar-18.2.sentence-1'>.</a></div></div></li><li id='condvar-18.3'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-18.3'>(18.3)</a></div><div class='texpara'><div id='condvar-18.3.sentence-1' class='sentence'>The function will unblock when signaled by a call to <span class='texttt'>notify_<span class='shy'></span>one<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, a call to <span class='texttt'>notify_<span class='shy'></span>all<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
expiration of the absolute timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by <span class='texttt'>abs_<span class='shy'></span>time</span>,
or spuriously<a class='hidden_link' href='#condvar-18.3.sentence-1'>.</a></div></div></li><li id='condvar-18.4'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-18.4'>(18.4)</a></div><div class='texpara'><div id='condvar-18.4.sentence-1' class='sentence'>If the function exits via an exception, <span class='texttt'>lock<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is called prior to exiting the function<a class='hidden_link' href='#condvar-18.4.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='para' id='condvar-19'><div class='marginalizedparent'><a class='marginalized' href='#condvar-19'>19</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9068'>#</a></div><div class='texpara'><div id='condvar-19.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread<a class='hidden_link' href='#condvar-19.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-20'><div class='marginalizedparent'><a class='marginalized' href='#condvar-20'>20</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9073'>#</a></div><div class='texpara'><div id='condvar-20.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>timeout</span> if
the absolute timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by <span class='texttt'>abs_<span class='shy'></span>time</span> expired,
otherwise <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>no_<span class='shy'></span>timeout</span><a class='hidden_link' href='#condvar-20.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-21'><div class='marginalizedparent'><a class='marginalized' href='#condvar-21'>21</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9079'>#</a></div><div class='texpara'><div id='condvar-21.sentence-1' class='sentence'><i >Throws</i>: Timeout-related
exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#condvar-21.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-22'><div class='marginalizedparent'><a class='marginalized' href='#condvar-22'>22</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9084'>#</a></div><div class='texpara'><div id='condvar-22.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#condvar-22.sentence-1'>.</a></div> <div id='condvar-note-4' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-4'>4</a></i>:&ensp;<div id='condvar-22.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#condvar-22.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable,wait_for'><div id='lib:wait_for,condition_variable'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_for,condition_variable'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>cv_status wait_for<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                     <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='condvar-23'><div class='marginalizedparent'><a class='marginalized' href='#condvar-23'>23</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9101'>#</a></div><div class='texpara'><div id='condvar-23.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread, and either
<ul class='itemize'><li id='condvar-23.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-23.1'>(23.1)</a></div>no other thread is waiting on this <span class='texttt'>condition_<span class='shy'></span>variable</span> object or</li><li id='condvar-23.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-23.2'>(23.2)</a></div><span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns the same value for each of the <span class='texttt'>lock</span> arguments
supplied by all concurrently waiting (via <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>, or
<span class='texttt'>wait_<span class='shy'></span>until</span>) threads<a class='hidden_link' href='#condvar-23.sentence-1'>.</a></li></ul></div></div></div></div><div class='para' id='condvar-24'><div class='marginalizedparent'><a class='marginalized' href='#condvar-24'>24</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9112'>#</a></div><div class='texpara'><div id='condvar-24.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>return</span> wait_until<span class='parenthesis'>(</span>lock, chrono<span class='operator'>::</span>steady_clock<span class='operator'>::</span>now<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>+</span> rel_time<span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='para' id='condvar-25'><div class='marginalizedparent'><a class='marginalized' href='#condvar-25'>25</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9119'>#</a></div><div class='texpara'><div id='condvar-25.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread<a class='hidden_link' href='#condvar-25.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-26'><div class='marginalizedparent'><a class='marginalized' href='#condvar-26'>26</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9124'>#</a></div><div class='texpara'><div id='condvar-26.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>timeout</span> if
the relative timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by <span class='texttt'>rel_<span class='shy'></span>time</span> expired,
otherwise <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>no_<span class='shy'></span>timeout</span><a class='hidden_link' href='#condvar-26.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-27'><div class='marginalizedparent'><a class='marginalized' href='#condvar-27'>27</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9130'>#</a></div><div class='texpara'><div id='condvar-27.sentence-1' class='sentence'><i >Throws</i>: Timeout-related
exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#condvar-27.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-28'><div class='marginalizedparent'><a class='marginalized' href='#condvar-28'>28</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9135'>#</a></div><div class='texpara'><div id='condvar-28.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate</span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#condvar-28.sentence-1'>.</a></div> <div id='condvar-note-5' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-5'>5</a></i>:&ensp;<div id='condvar-28.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#condvar-28.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable,wait_until_'><div id='lib:wait_until,condition_variable_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_until,condition_variable_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> wait_until<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                  <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time,
                  Predicate pred<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='condvar-29'><div class='marginalizedparent'><a class='marginalized' href='#condvar-29'>29</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9153'>#</a></div><div class='texpara'><div id='condvar-29.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is
locked by the calling thread, and either
<ul class='itemize'><li id='condvar-29.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-29.1'>(29.1)</a></div>no other thread is waiting on this <span class='texttt'>condition_<span class='shy'></span>variable</span> object or</li><li id='condvar-29.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-29.2'>(29.2)</a></div><span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns the same value for each of the <span class='texttt'>lock</span>
arguments supplied by all concurrently waiting (via <span class='texttt'>wait</span>,
<span class='texttt'>wait_<span class='shy'></span>for</span>, or <span class='texttt'>wait_<span class='shy'></span>until</span>) threads<a class='hidden_link' href='#condvar-29.sentence-1'>.</a></li></ul></div></div></div></div><div class='para' id='condvar-30'><div class='marginalizedparent'><a class='marginalized' href='#condvar-30'>30</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9164'>#</a></div><div class='texpara'><div id='condvar-30.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>while</span> <span class='parenthesis'>(</span><span class='operator'>!</span>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
  <span class='keyword'>if</span> <span class='parenthesis'>(</span>wait_until<span class='parenthesis'>(</span>lock, abs_time<span class='parenthesis'>)</span> <span class='operator'>=</span><span class='operator'>=</span> cv_status<span class='operator'>::</span>timeout<span class='parenthesis'>)</span>
    <span class='keyword'>return</span> pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
<span class='keyword'>return</span> <span class='literal'>true</span>;
</span></div></div></div></div><div class='para' id='condvar-31'><div class='marginalizedparent'><a class='marginalized' href='#condvar-31'>31</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9174'>#</a></div><div class='texpara'><div id='condvar-31.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread<a class='hidden_link' href='#condvar-31.sentence-1'>.</a></div></div></div></div><div class='para nonNormativeOnly' id='condvar-32'><div class='marginalizedparent'><a class='marginalized' href='#condvar-32'>32</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9179'>#</a></div><div class='texpara'><div id='condvar-note-6' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-6'>6</a></i>:&ensp;<div id='condvar-32.sentence-1' class='sentence'>The returned value indicates whether the predicate evaluated to
<span class='texttt'><span class='literal'>true</span></span> regardless of whether the timeout was triggered<a class='hidden_link' href='#condvar-32.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='condvar-33'><div class='marginalizedparent'><a class='marginalized' href='#condvar-33'>33</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9185'>#</a></div><div class='texpara'><div id='condvar-33.sentence-1' class='sentence'><i >Throws</i>: Timeout-related
exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) or any exception thrown by <span class='texttt'>pred</span><a class='hidden_link' href='#condvar-33.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-34'><div class='marginalizedparent'><a class='marginalized' href='#condvar-34'>34</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9190'>#</a></div><div class='texpara'><div id='condvar-34.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#condvar-34.sentence-1'>.</a></div> <div id='condvar-note-7' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-7'>7</a></i>:&ensp;<div id='condvar-34.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#condvar-34.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable,wait_for_'><div id='lib:wait_for,condition_variable_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_for,condition_variable_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> wait_for<span class='parenthesis'>(</span>unique_lock<span class='anglebracket'>&lt;</span>mutex<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> lock,
                <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time,
                Predicate pred<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='condvar-35'><div class='marginalizedparent'><a class='marginalized' href='#condvar-35'>35</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9208'>#</a></div><div class='texpara'><div id='condvar-35.sentence-1' class='sentence'><i >Preconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread, and either
<ul class='itemize'><li id='condvar-35.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-35.1'>(35.1)</a></div>no other thread is waiting on this <span class='texttt'>condition_<span class='shy'></span>variable</span> object or</li><li id='condvar-35.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvar-35.2'>(35.2)</a></div><span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> returns the same value for each of the <span class='texttt'>lock</span> arguments
supplied by all concurrently waiting (via <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>, or
<span class='texttt'>wait_<span class='shy'></span>until</span>) threads<a class='hidden_link' href='#condvar-35.sentence-1'>.</a></li></ul></div></div></div></div><div class='para' id='condvar-36'><div class='marginalizedparent'><a class='marginalized' href='#condvar-36'>36</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9222'>#</a></div><div class='texpara'><div id='condvar-36.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>return</span> wait_until<span class='parenthesis'>(</span>lock, chrono<span class='operator'>::</span>steady_clock<span class='operator'>::</span>now<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>+</span> rel_time, std<span class='operator'>::</span>move<span class='parenthesis'>(</span>pred<span class='parenthesis'>)</span><span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='para nonNormativeOnly' id='condvar-37'><div class='marginalizedparent'><a class='marginalized' href='#condvar-37'>37</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9229'>#</a></div><div class='texpara'><div id='condvar-note-8' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-8'>8</a></i>:&ensp;<div id='condvar-37.sentence-1' class='sentence'>There is no blocking if <span class='texttt'>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is initially <span class='texttt'><span class='literal'>true</span></span>, even if the
timeout has already expired<a class='hidden_link' href='#condvar-37.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='condvar-38'><div class='marginalizedparent'><a class='marginalized' href='#condvar-38'>38</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9235'>#</a></div><div class='texpara'><div id='condvar-38.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock<span class='operator'>.</span>owns_<span class='shy'></span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is <span class='texttt'><span class='literal'>true</span></span> and <span class='texttt'>lock<span class='operator'>.</span>mutex<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is locked by the calling thread<a class='hidden_link' href='#condvar-38.sentence-1'>.</a></div></div></div></div><div class='para nonNormativeOnly' id='condvar-39'><div class='marginalizedparent'><a class='marginalized' href='#condvar-39'>39</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9240'>#</a></div><div class='texpara'><div id='condvar-note-9' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-9'>9</a></i>:&ensp;<div id='condvar-39.sentence-1' class='sentence'>The returned value indicates whether the predicate evaluates to <span class='texttt'><span class='literal'>true</span></span>
regardless of whether the timeout was triggered<a class='hidden_link' href='#condvar-39.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='condvar-40'><div class='marginalizedparent'><a class='marginalized' href='#condvar-40'>40</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9246'>#</a></div><div class='texpara'><div id='condvar-40.sentence-1' class='sentence'><i >Throws</i>: Timeout-related
exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) or any exception thrown by <span class='texttt'>pred</span><a class='hidden_link' href='#condvar-40.sentence-1'>.</a></div></div></div></div><div class='para' id='condvar-41'><div class='marginalizedparent'><a class='marginalized' href='#condvar-41'>41</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9251'>#</a></div><div class='texpara'><div id='condvar-41.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#condvar-41.sentence-1'>.</a></div> <div id='condvar-note-10' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvar-note-10'>10</a></i>:&ensp;<div id='condvar-41.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#condvar-41.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div></div><div id='condvarany' class='section'><h3 ><a class='secnum' href='#condvarany' style='min-width:80pt'>32.7.5</a> Class <span class='texttt'>condition_<span class='shy'></span>variable_<span class='shy'></span>any</span> <a class='abbr_ref' href='thread.condition.condvarany'>[thread.condition.condvarany]</a></h3><div id='condvarany.general' class='section'><h4 ><a class='secnum' href='#condvarany.general' style='min-width:95pt'>32.7.5.1</a> General <a class='abbr_ref' href='thread.condition.condvarany.general'>[thread.condition.condvarany.general]</a></h4><div class='para' id='condvarany.general-1'><div class='marginalizedparent'><a class='marginalized' href='#condvarany.general-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9264'>#</a></div><div class='texpara'><div id='condvarany.general-1.sentence-1' class='sentence'>In <a href='#condvarany' title='32.7.5&emsp;Class condition_&shy;variable_&shy;any'>[thread.<span class='shy'></span>condition.<span class='shy'></span>condvarany]</a>,
template arguments for template parameters named <span class='texttt'>Lock</span>
shall meet the <a href='thread.req.lockable.basic#:Cpp17BasicLockable' title='32.2.5.2&emsp;Cpp17BasicLockable requirements&emsp;[thread.req.lockable.basic]'><i >Cpp17BasicLockable</i></a>
requirements (<a href='thread.req.lockable.basic' title='32.2.5.2&emsp;Cpp17BasicLockable requirements'>[thread.<span class='shy'></span>req.<span class='shy'></span>lockable.<span class='shy'></span>basic]</a>)<a class='hidden_link' href='#condvarany.general-1.sentence-1'>.</a></div> <div id='condvarany.general-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvarany.general-note-1'>1</a></i>:&ensp;<div id='condvarany.general-1.sentence-2' class='sentence'>All of the standard
mutex types meet this requirement<a class='hidden_link' href='#condvarany.general-1.sentence-2'>.</a></div> <div id='condvarany.general-1.sentence-3' class='sentence'>If a type other than one of the
standard mutex types or a <span class='texttt'>unique_<span class='shy'></span>lock</span> wrapper for a standard mutex type
is used with <span class='texttt'>condition_<span class='shy'></span>variable_<span class='shy'></span>any</span>, any
necessary synchronization is assumed to be in place with respect to the predicate associated
with the <span class='texttt'>condition_<span class='shy'></span>variable_<span class='shy'></span>any</span> instance<a class='hidden_link' href='#condvarany.general-1.sentence-3'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div><div class='texpara'><span id='lib:condition_variable_any'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:condition_variable_any'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> std <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> condition_variable_any <span class='curlybracket'>{</span>
  <span class='keyword'>public</span><span class='operator'>:</span>
    <span class="added">constexpr </span>condition_variable_any<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
    <span class="added">constexpr </span><span class='operator'>~</span>condition_variable_any<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;

    condition_variable_any<span class='parenthesis'>(</span><span class='keyword'>const</span> condition_variable_any<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;
    condition_variable_any<span class='operator'>&amp;</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='parenthesis'>(</span><span class='keyword'>const</span> condition_variable_any<span class='operator'>&amp;</span><span class='parenthesis'>)</span> <span class='operator'>=</span> <span class='keyword'>delete</span>;

    <span class="added">constexpr </span><span class='keyword'>void</span> notify_one<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
    <span class="added">constexpr </span><span class='keyword'>void</span> notify_all<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;

    <span class='comment'>// <a href='#thread.condvarany.wait' title='32.7.5.2&emsp;Noninterruptible waits'>[thread.<span class='shy'></span>condvarany.<span class='shy'></span>wait]</a>, noninterruptible waits</span>
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, Predicate pred<span class='parenthesis'>)</span>;

    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>cv_status wait_until<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> wait_until<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time,
                      Predicate pred<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span>cv_status wait_for<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> wait_for<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time, Predicate pred<span class='parenthesis'>)</span>;

    <span class='comment'>// <a href='#thread.condvarany.intwait' title='32.7.5.3&emsp;Interruptible waits'>[thread.<span class='shy'></span>condvarany.<span class='shy'></span>intwait]</a>, interruptible waits</span>
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> wait<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, stop_token stoken, Predicate pred<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> wait_until<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, stop_token stoken,
                      <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time, Predicate pred<span class='parenthesis'>)</span>;
    <span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
      <span class="added">constexpr </span><span class='keyword'>bool</span> wait_for<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, stop_token stoken,
                    <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time, Predicate pred<span class='parenthesis'>)</span>;
  <span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div></div><div class='texpara'><div id='lib:condition_variable_any,constructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:condition_variable_any,constructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span>condition_variable_any<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='condvarany.general-2'><div class='marginalizedparent'><a class='marginalized' href='#condvarany.general-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9327'>#</a></div><div class='texpara'><div id='condvarany.general-2.sentence-1' class='sentence'><i >Throws</i>: <span class='texttt'>bad_<span class='shy'></span>alloc</span> or <span class='texttt'>system_<span class='shy'></span>error</span> when an exception is
required (<a href='thread.req.exception' title='32.2.2&emsp;Exceptions'>[thread.<span class='shy'></span>req.<span class='shy'></span>exception]</a>)<a class='hidden_link' href='#condvarany.general-2.sentence-1'>.</a></div></div></div></div><div class='para' id='condvarany.general-3'><div class='marginalizedparent'><a class='marginalized' href='#condvarany.general-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9332'>#</a></div><div class='texpara'><div id='condvarany.general-3.sentence-1' class='sentence'><i >Error conditions</i>: <ul class='itemize'><li id='condvarany.general-3.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvarany.general-3.1'>(3.1)</a></div><div class='texpara'><div id='condvarany.general-3.1.sentence-1' class='sentence'><span class='texttt'>resource_<span class='shy'></span>unavailable_<span class='shy'></span>try_<span class='shy'></span>again</span> — if some non-memory resource
limitation prevents initialization<a class='hidden_link' href='#condvarany.general-3.1.sentence-1'>.</a></div></div></li><li id='condvarany.general-3.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#condvarany.general-3.2'>(3.2)</a></div><div class='texpara'><div id='condvarany.general-3.2.sentence-1' class='sentence'><span class='texttt'>operation_<span class='shy'></span>not_<span class='shy'></span>permitted</span> — if the thread does not have the
privilege to perform the operation<a class='hidden_link' href='#condvarany.general-3.2.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,destructor'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:condition_variable_any,destructor'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='operator'>~</span>condition_variable_any<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</code></div></div></div><div class='para' id='condvarany.general-4'><div class='marginalizedparent'><a class='marginalized' href='#condvarany.general-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9349'>#</a></div><div class='texpara'><div id='condvarany.general-4.sentence-1' class='sentence'><i >Preconditions</i>: There is no thread blocked on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#condvarany.general-4.sentence-1'>.</a></div> <div id='condvarany.general-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#condvarany.general-note-2'>2</a></i>:&ensp;<div id='condvarany.general-4.sentence-2' class='sentence'>That is, all
threads have been notified; they can subsequently block on the lock specified in the
wait<a class='hidden_link' href='#condvarany.general-4.sentence-2'>.</a></div> <div id='condvarany.general-4.sentence-3' class='sentence'>This relaxes the usual rules, which would have required all wait calls to happen before
destruction<a class='hidden_link' href='#condvarany.general-4.sentence-3'>.</a></div> <div id='condvarany.general-4.sentence-4' class='sentence'>Only the notification to unblock the wait needs to happen before destruction<a class='hidden_link' href='#condvarany.general-4.sentence-4'>.</a></div> <div id='condvarany.general-4.sentence-5' class='sentence'>Undefined behavior ensues if a thread waits on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span> once the destructor has
been started, especially when the waiting threads are calling the wait functions in a loop or
using the overloads of <span class='texttt'>wait</span>, <span class='texttt'>wait_<span class='shy'></span>for</span>, or <span class='texttt'>wait_<span class='shy'></span>until</span> that take a predicate<a class='hidden_link' href='#condvarany.general-4.sentence-5'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,notify_one'><div id='lib:notify_one,condition_variable_any'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:notify_one,condition_variable_any'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> notify_one<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='condvarany.general-5'><div class='marginalizedparent'><a class='marginalized' href='#condvarany.general-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9370'>#</a></div><div class='texpara'><div id='condvarany.general-5.sentence-1' class='sentence'><i >Effects</i>: If any threads are blocked waiting for <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span>, unblocks one of those threads<a class='hidden_link' href='#condvarany.general-5.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,notify_all'><div id='lib:notify_all,condition_variable_any'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:notify_all,condition_variable_any'>🔗</a></div><code class='itemdeclcode'><span class="added">constexpr </span><span class='keyword'>void</span> notify_all<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='keyword'>noexcept</span>;
</code></div></div></div></div><div class='para' id='condvarany.general-6'><div class='marginalizedparent'><a class='marginalized' href='#condvarany.general-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9381'>#</a></div><div class='texpara'><div id='condvarany.general-6.sentence-1' class='sentence'><i >Effects</i>: Unblocks all threads that are blocked waiting for <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#condvarany.general-6.sentence-1'>.</a></div></div></div></div></div><div id='thread.condvarany.wait' class='section'><h4 ><a class='secnum' href='#thread.condvarany.wait' style='min-width:95pt'>32.7.5.2</a> Noninterruptible waits <a class='abbr_ref' href='thread.condvarany.wait'>[thread.condvarany.wait]</a></h4><div class='texpara'><div id='lib:condition_variable_any,wait'><div id='lib:wait,condition_variable_any'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait,condition_variable_any'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.condvarany.wait-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9395'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-1.sentence-1' class='sentence'><a class='index' id=':block_(execution)_'></a><i >Effects</i>: <ul class='itemize'><li id='thread.condvarany.wait-1.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.condvarany.wait-1.1'>(1.1)</a></div><div class='texpara'><div id='thread.condvarany.wait-1.1.sentence-1' class='sentence'>Atomically calls <span class='texttt'>lock<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> and blocks on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#thread.condvarany.wait-1.1.sentence-1'>.</a></div></div></li><li id='thread.condvarany.wait-1.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.condvarany.wait-1.2'>(1.2)</a></div><div class='texpara'><div id='thread.condvarany.wait-1.2.sentence-1' class='sentence'>When unblocked, calls <span class='texttt'>lock<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> (possibly blocking on the lock) and returns<a class='hidden_link' href='#thread.condvarany.wait-1.2.sentence-1'>.</a></div></div></li><li id='thread.condvarany.wait-1.3'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.condvarany.wait-1.3'>(1.3)</a></div><div class='texpara'><div id='thread.condvarany.wait-1.3.sentence-1' class='sentence'>The function will unblock when signaled by a call to <span class='texttt'>notify_<span class='shy'></span>one<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
a call to <span class='texttt'>notify_<span class='shy'></span>all<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, or spuriously<a class='hidden_link' href='#thread.condvarany.wait-1.3.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='para' id='thread.condvarany.wait-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9405'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-2.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock</span> is locked by the calling thread<a class='hidden_link' href='#thread.condvarany.wait-2.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9409'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-3.sentence-1' class='sentence'><i >Throws</i>: Nothing<a class='hidden_link' href='#thread.condvarany.wait-3.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9413'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-4.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#thread.condvarany.wait-4.sentence-1'>.</a></div> <div id='thread.condvarany.wait-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.wait-note-1'>1</a></i>:&ensp;<div id='thread.condvarany.wait-4.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#thread.condvarany.wait-4.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,wait_'><div id='lib:wait,condition_variable_any_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait,condition_variable_any_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>void</span> wait<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, Predicate pred<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.condvarany.wait-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9429'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-5.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>while</span> <span class='parenthesis'>(</span><span class='operator'>!</span>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
  wait<span class='parenthesis'>(</span>lock<span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,wait_until'><div id='lib:wait_until,condition_variable_any'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_until,condition_variable_any'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>cv_status wait_until<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.condvarany.wait-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9445'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-6.sentence-1' class='sentence'><i >Effects</i>: <ul class='itemize'><li id='thread.condvarany.wait-6.1'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.condvarany.wait-6.1'>(6.1)</a></div><div class='texpara'><div id='thread.condvarany.wait-6.1.sentence-1' class='sentence'><a class='index' id=':block_(execution)__'></a>Atomically calls <span class='texttt'>lock<span class='operator'>.</span>unlock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> and blocks on <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span><a class='hidden_link' href='#thread.condvarany.wait-6.1.sentence-1'>.</a></div></div></li><li id='thread.condvarany.wait-6.2'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.condvarany.wait-6.2'>(6.2)</a></div><div class='texpara'><div id='thread.condvarany.wait-6.2.sentence-1' class='sentence'>When unblocked, calls <span class='texttt'>lock<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> (possibly blocking on the lock) and returns<a class='hidden_link' href='#thread.condvarany.wait-6.2.sentence-1'>.</a></div></div></li><li id='thread.condvarany.wait-6.3'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.condvarany.wait-6.3'>(6.3)</a></div><div class='texpara'><div id='thread.condvarany.wait-6.3.sentence-1' class='sentence'>The function will unblock when signaled by a call to <span class='texttt'>notify_<span class='shy'></span>one<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>, a call to <span class='texttt'>notify_<span class='shy'></span>all<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>,
expiration of the absolute timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by <span class='texttt'>abs_<span class='shy'></span>time</span>,
or spuriously<a class='hidden_link' href='#thread.condvarany.wait-6.3.sentence-1'>.</a></div></div></li><li id='thread.condvarany.wait-6.4'><div class='marginalizedparent' style='left:-39mm'><a class='marginalized' href='#thread.condvarany.wait-6.4'>(6.4)</a></div><div class='texpara'><div id='thread.condvarany.wait-6.4.sentence-1' class='sentence'>If the function exits via an exception, <span class='texttt'>lock<span class='operator'>.</span>lock<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is called prior to exiting the function<a class='hidden_link' href='#thread.condvarany.wait-6.4.sentence-1'>.</a></div></div></li></ul></div></div></div></div><div class='para' id='thread.condvarany.wait-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9464'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-7.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock</span> is locked by the calling thread<a class='hidden_link' href='#thread.condvarany.wait-7.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9468'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-8.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>timeout</span> if
the absolute timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by <span class='texttt'>abs_<span class='shy'></span>time</span> expired,
otherwise <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>no_<span class='shy'></span>timeout</span><a class='hidden_link' href='#thread.condvarany.wait-8.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9474'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-9.sentence-1' class='sentence'><i >Throws</i>: Timeout-related
exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#thread.condvarany.wait-9.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9479'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-10.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#thread.condvarany.wait-10.sentence-1'>.</a></div> <div id='thread.condvarany.wait-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.wait-note-2'>2</a></i>:&ensp;<div id='thread.condvarany.wait-10.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#thread.condvarany.wait-10.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,wait_for'><div id='lib:wait_for,condition_variable_any'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_for,condition_variable_any'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span>cv_status wait_for<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.condvarany.wait-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9495'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-11.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>return</span> wait_until<span class='parenthesis'>(</span>lock, chrono<span class='operator'>::</span>steady_clock<span class='operator'>::</span>now<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>+</span> rel_time<span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='para' id='thread.condvarany.wait-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9502'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-12.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock</span> is locked by the calling thread<a class='hidden_link' href='#thread.condvarany.wait-12.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9506'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-13.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>timeout</span> if
the relative timeout (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>) specified by <span class='texttt'>rel_<span class='shy'></span>time</span> expired,
otherwise <span class='texttt'>cv_<span class='shy'></span>status<span class='operator'>&#x200b;::&#x200b;</span>no_<span class='shy'></span>timeout</span><a class='hidden_link' href='#thread.condvarany.wait-13.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-14'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-14'>14</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9512'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-14.sentence-1' class='sentence'><i >Throws</i>: Timeout-related
exceptions (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>)<a class='hidden_link' href='#thread.condvarany.wait-14.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.wait-15'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-15'>15</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9517'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-15.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition, <span class='texttt'>terminate</span>
is invoked (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#thread.condvarany.wait-15.sentence-1'>.</a></div> <div id='thread.condvarany.wait-note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.wait-note-3'>3</a></i>:&ensp;<div id='thread.condvarany.wait-15.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#thread.condvarany.wait-15.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,wait_until_'><div id='lib:wait_until,condition_variable_any_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_until,condition_variable_any_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> wait_until<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time, Predicate pred<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.condvarany.wait-16'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-16'>16</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9533'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-16.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>while</span> <span class='parenthesis'>(</span><span class='operator'>!</span>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
  <span class='keyword'>if</span> <span class='parenthesis'>(</span>wait_until<span class='parenthesis'>(</span>lock, abs_time<span class='parenthesis'>)</span> <span class='operator'>=</span><span class='operator'>=</span> cv_status<span class='operator'>::</span>timeout<span class='parenthesis'>)</span>
    <span class='keyword'>return</span> pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
<span class='keyword'>return</span> <span class='literal'>true</span>;
</span></div></div></div></div><div class='para nonNormativeOnly' id='thread.condvarany.wait-17'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-17'>17</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9543'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-note-4' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.wait-note-4'>4</a></i>:&ensp;<div id='thread.condvarany.wait-17.sentence-1' class='sentence'>There is no blocking if <span class='texttt'>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is initially <span class='texttt'><span class='literal'>true</span></span>, or
if the timeout has already expired<a class='hidden_link' href='#thread.condvarany.wait-17.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para nonNormativeOnly' id='thread.condvarany.wait-18'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-18'>18</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9549'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-note-5' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.wait-note-5'>5</a></i>:&ensp;<div id='thread.condvarany.wait-18.sentence-1' class='sentence'>The returned value indicates whether the predicate evaluates to <span class='texttt'><span class='literal'>true</span></span>
regardless of whether the timeout was triggered<a class='hidden_link' href='#thread.condvarany.wait-18.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div id='lib:condition_variable_any,wait_for_'><div id='lib:wait_for,condition_variable_any_'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:wait_for,condition_variable_any_'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> wait_for<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time, Predicate pred<span class='parenthesis'>)</span>;
</code></div></div></div></div><div class='para' id='thread.condvarany.wait-19'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.wait-19'>19</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9563'>#</a></div><div class='texpara'><div id='thread.condvarany.wait-19.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>return</span> wait_until<span class='parenthesis'>(</span>lock, chrono<span class='operator'>::</span>steady_clock<span class='operator'>::</span>now<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>+</span> rel_time, std<span class='operator'>::</span>move<span class='parenthesis'>(</span>pred<span class='parenthesis'>)</span><span class='parenthesis'>)</span>;
</span></div></div></div></div></div><div id='thread.condvarany.intwait' class='section'><h4 ><a class='secnum' href='#thread.condvarany.intwait' style='min-width:95pt'>32.7.5.3</a> Interruptible waits <a class='abbr_ref' href='thread.condvarany.intwait'>[thread.condvarany.intwait]</a></h4><div class='para' id='thread.condvarany.intwait-1'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9573'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-1.sentence-1' class='sentence'>The following wait functions will be notified
when there is a stop request on the passed <span class='texttt'>stop_<span class='shy'></span>token</span><a class='hidden_link' href='#thread.condvarany.intwait-1.sentence-1'>.</a></div> <div id='thread.condvarany.intwait-1.sentence-2' class='sentence'>In that case the functions return immediately,
returning <span class='texttt'><span class='literal'>false</span></span> if the predicate evaluates to <span class='texttt'><span class='literal'>false</span></span><a class='hidden_link' href='#thread.condvarany.intwait-1.sentence-2'>.</a></div></div></div><div class='texpara'><div class='itemdecl' id='thread.condvarany.intwait-itemdecl:1'><div class='marginalizedparent'><a class='itemDeclLink' href='#thread.condvarany.intwait-itemdecl:1'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> wait<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, stop_token stoken, Predicate pred<span class='parenthesis'>)</span>;
</code></div></div><div class='para' id='thread.condvarany.intwait-2'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9585'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-2.sentence-1' class='sentence'><i >Effects</i>: Registers for the duration of this call <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span>
to get notified on a stop request on <span class='texttt'>stoken</span>
during this call and then equivalent to:
<span class='codeblock'><span class='keyword'>while</span> <span class='parenthesis'>(</span><span class='operator'>!</span>stoken<span class='operator'>.</span>stop_requested<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  <span class='keyword'>if</span> <span class='parenthesis'>(</span>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
    <span class='keyword'>return</span> <span class='literal'>true</span>;
  wait<span class='parenthesis'>(</span>lock<span class='parenthesis'>)</span>;
<span class='curlybracket'>}</span>
<span class='keyword'>return</span> pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='para nonNormativeOnly' id='thread.condvarany.intwait-3'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9599'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-note-1' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.intwait-note-1'>1</a></i>:&ensp;<div id='thread.condvarany.intwait-3.sentence-1' class='sentence'>The returned value indicates whether the predicate evaluated to
<span class='texttt'><span class='literal'>true</span></span> regardless of whether there was a stop request<a class='hidden_link' href='#thread.condvarany.intwait-3.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='thread.condvarany.intwait-4'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9605'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-4.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock</span> is locked by the calling thread<a class='hidden_link' href='#thread.condvarany.intwait-4.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.intwait-5'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-5'>5</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9609'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-5.sentence-1' class='sentence'><i >Throws</i>: Any exception thrown by <span class='texttt'>pred</span><a class='hidden_link' href='#thread.condvarany.intwait-5.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.intwait-6'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-6'>6</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9613'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-6.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition,
<span class='texttt'>terminate</span> is called (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#thread.condvarany.intwait-6.sentence-1'>.</a></div> <div id='thread.condvarany.intwait-note-2' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.intwait-note-2'>2</a></i>:&ensp;<div id='thread.condvarany.intwait-6.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#thread.condvarany.intwait-6.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div class='itemdecl' id='thread.condvarany.intwait-itemdecl:2'><div class='marginalizedparent'><a class='itemDeclLink' href='#thread.condvarany.intwait-itemdecl:2'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Clock, <span class='keyword'>class</span> Duration, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> wait_until<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, stop_token stoken,
                  <span class='keyword'>const</span> chrono<span class='operator'>::</span>time_point<span class='anglebracket'>&lt;</span>Clock, Duration<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> abs_time, Predicate pred<span class='parenthesis'>)</span>;
</code></div></div><div class='para' id='thread.condvarany.intwait-7'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-7'>7</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9629'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-7.sentence-1' class='sentence'><i >Effects</i>: Registers for the duration of this call <span class='texttt'><span class='operator'>*</span><span class='keyword'>this</span></span>
to get notified on a stop request on <span class='texttt'>stoken</span>
during this call and then equivalent to:
<span class='codeblock'><span class='keyword'>while</span> <span class='parenthesis'>(</span><span class='operator'>!</span>stoken<span class='operator'>.</span>stop_requested<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  <span class='keyword'>if</span> <span class='parenthesis'>(</span>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
    <span class='keyword'>return</span> <span class='literal'>true</span>;
  <span class='keyword'>if</span> <span class='parenthesis'>(</span>wait_until<span class='parenthesis'>(</span>lock, abs_time<span class='parenthesis'>)</span> <span class='operator'>=</span><span class='operator'>=</span> cv_status<span class='operator'>::</span>timeout<span class='parenthesis'>)</span>
    <span class='keyword'>return</span> pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
<span class='curlybracket'>}</span>
<span class='keyword'>return</span> pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
</span></div></div></div></div><div class='para nonNormativeOnly' id='thread.condvarany.intwait-8'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-8'>8</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9644'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-note-3' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.intwait-note-3'>3</a></i>:&ensp;<div id='thread.condvarany.intwait-8.sentence-1' class='sentence'>There is no blocking if <span class='texttt'>pred<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> is initially <span class='texttt'><span class='literal'>true</span></span>,
<span class='texttt'>stoken<span class='operator'>.</span>stop_<span class='shy'></span>requested<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> was already <span class='texttt'><span class='literal'>true</span></span>
or the timeout has already expired<a class='hidden_link' href='#thread.condvarany.intwait-8.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para nonNormativeOnly' id='thread.condvarany.intwait-9'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-9'>9</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9651'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-note-4' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.intwait-note-4'>4</a></i>:&ensp;<div id='thread.condvarany.intwait-9.sentence-1' class='sentence'>The returned value indicates whether the predicate evaluated to <span class='texttt'><span class='literal'>true</span></span>
regardless of whether the timeout was triggered or a stop request was made<a class='hidden_link' href='#thread.condvarany.intwait-9.sentence-1'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='para' id='thread.condvarany.intwait-10'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-10'>10</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9657'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-10.sentence-1' class='sentence'><i >Postconditions</i>: <span class='texttt'>lock</span> is locked by the calling thread<a class='hidden_link' href='#thread.condvarany.intwait-10.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.intwait-11'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-11'>11</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9661'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-11.sentence-1' class='sentence'><i >Throws</i>: Timeout-related exceptions  (<a href='thread.req.timing' title='32.2.4&emsp;Timing specifications'>[thread.<span class='shy'></span>req.<span class='shy'></span>timing]</a>),
or any exception thrown by <span class='texttt'>pred</span><a class='hidden_link' href='#thread.condvarany.intwait-11.sentence-1'>.</a></div></div></div></div><div class='para' id='thread.condvarany.intwait-12'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-12'>12</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9666'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-12.sentence-1' class='sentence'><i >Remarks</i>: If the function fails to meet the postcondition,
<span class='texttt'>terminate</span> is called (<a href='except.terminate' title='14.6.2&emsp;The std&#x200b;::&#x200b;terminate function'>[except.<span class='shy'></span>terminate]</a>)<a class='hidden_link' href='#thread.condvarany.intwait-12.sentence-1'>.</a></div> <div id='thread.condvarany.intwait-note-5' class='note'><div class='texpara'>[<i>Note&nbsp;<a href='#thread.condvarany.intwait-note-5'>5</a></i>:&ensp;<div id='thread.condvarany.intwait-12.sentence-2' class='sentence'>This can happen if the re-locking of the mutex throws an exception<a class='hidden_link' href='#thread.condvarany.intwait-12.sentence-2'>.</a></div> —&nbsp;<i>end note</i>]</div></div></div></div></div><div class='texpara'><div class='itemdecl' id='thread.condvarany.intwait-itemdecl:3'><div class='marginalizedparent'><a class='itemDeclLink' href='#thread.condvarany.intwait-itemdecl:3'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><span class='keyword'>class</span> Lock, <span class='keyword'>class</span> Rep, <span class='keyword'>class</span> Period, <span class='keyword'>class</span> Predicate<span class='anglebracket'>&gt;</span>
  <span class="added">constexpr </span><span class='keyword'>bool</span> wait_for<span class='parenthesis'>(</span>Lock<span class='operator'>&amp;</span> lock, stop_token stoken,
                <span class='keyword'>const</span> chrono<span class='operator'>::</span>duration<span class='anglebracket'>&lt;</span>Rep, Period<span class='anglebracket'>&gt;</span><span class='operator'>&amp;</span> rel_time, Predicate pred<span class='parenthesis'>)</span>;
</code></div></div><div class='para' id='thread.condvarany.intwait-13'><div class='marginalizedparent'><a class='marginalized' href='#thread.condvarany.intwait-13'>13</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='http://github.com/Eelis/draft/tree/244a32502dbf22121f7f8f4c5d557521e15b673c/source/threads.tex#L9682'>#</a></div><div class='texpara'><div id='thread.condvarany.intwait-13.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>return</span> wait_until<span class='parenthesis'>(</span>lock, std<span class='operator'>::</span>move<span class='parenthesis'>(</span>stoken<span class='parenthesis'>)</span>, chrono<span class='operator'>::</span>steady_clock<span class='operator'>::</span>now<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='operator'>+</span> rel_time,
                  std<span class='operator'>::</span>move<span class='parenthesis'>(</span>pred<span class='parenthesis'>)</span><span class='parenthesis'>)</span>;
</span></div></div></div></div></div></div>
</div>
</section><section data-related="feature-test-macro"><h3><a href="#feature-test-macro" id="feature-test-macro">Feature test macro</a></h3><div class="wording context">

<h4><a href="http://eel.is/c++draft/cpp.predefined">15.11 Predefined macro names [cpp.predefined]</a></h4><div class="para"><pre><code><div class="added">__cpp_constexpr_synchronization 20????L</div></code></pre></div>

<h4><a href="http://eel.is/c++draft/cpp.predefined">17.3.2 Header &lt;version&gt; synopsis [version.syn]</a></h4><div class="para"><pre><code><div class="added">#define __cpp_lib_constexpr_mutex 20????L                    // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_recursive_mutex 20????L          // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_timed_mutex 20????L              // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_timed_recursive_mutex 20????L    // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_shared_mutex 20????L             // also in &lt;shared_mutex&gt;
#define __cpp_lib_constexpr_shared_timed_mutex 20????L       // also in &lt;shared_mutex&gt;
#define __cpp_lib_constexpr_lock_guard 20????L               // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_scoped_lock 20????L              // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_unique_lock 20????L              // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_shared_lock 20????L              // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_call_once 20????L                // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_locking_algorithms 20????L       // also in &lt;mutex&gt;
#define __cpp_lib_constexpr_condition_variable 20????L     // also in &lt;condition_variable&gt;
#define __cpp_lib_constexpr_condition_variable_any 20????L // also in &lt;condition_variable&gt;</div></code></pre></div>

</div></section></section></article>

<script>
	const all_changes = document.querySelectorAll(".wording .added, .wording .removed, .wording .change");
	let position = null;
	
	function set_hash(id) {
		const elem = document.getElementById(id);
		if (elem) {
			elem.id = `${id}-tmp`;
		}
		window.location.hash = id;
		if (elem) {
			elem.id = id;
		}
		return elem;
	}
	
	function disable_highlight_on_previous() {
		if (position != null) {
			//window.location.href.match(/([^#]++)#.++/);
			//window.location.
			set_hash("no-change-selected");
			// hljs is messing with me
			document.getElementById(all_changes[position].id).classList.remove("selected-current");
		}
	}
	
	function scroll_into_view_if_needed(el, scroll_there = true) {
		if (scroll_there) {
			if (!element_is_visible_in_viewport(el)) {
				el.scrollIntoView({behavior: "smooth", block: "center", inline: "center" });
			} else {
				console.log("doesn't need to scroll?!");
			}
		}
		
		return el;
	}
	
	function highlight_index(i = null, scroll_there = true) {
		if (position !== null && i === position) {
			console.log(`disabling overlay: ${i} === ${position}`);
			disable_highlight_on_previous();
			let overlay = document.querySelector("#overlay");
			overlay.remove();
			position = null;
			return;
		}
		
		if (i !== null) {
			disable_highlight_on_previous();
			position = i;
		}
		
		
		let overlay = document.querySelector("#overlay");
		if (!overlay) {
			let overlay = document.createElement("div");
			overlay.id = "overlay";
			document.querySelector("body").appendChild(overlay);
		}
		
		set_hash(`change-${position}`);
		
		
		const current = document.getElementById(all_changes[position].id);
		current.classList.add("selected-current");
		const scroll_anchor = current.querySelector(".scroll-here")
		
		if (scroll_anchor) {
			return scroll_into_view_if_needed(scroll_anchor, scroll_there);
		}
		
		return scroll_into_view_if_needed(current, scroll_there);
	}
	
	function element_is_visible_in_viewport(el) {
	  const { top, left, bottom, right } = el.getBoundingClientRect();
	  const { innerHeight, innerWidth } = window;
		const zoneHeight = innerHeight/5;
		const zoneWidth = innerWidth/5;
		
	  return top >= zoneHeight && bottom <= (innerHeight-zoneHeight);
	};
	
	all_changes.forEach((e, i) => {
		e.style.cursor = "pointer";
		e.id = `change-${i}-real`;
		e.onclick = (ev) => {
			current = highlight_index(i);
			
			ev.alreadyProcessed = true;
		}
	});
	
	document.body.onclick = (ev) => {
		if (position !== null && !ev.alreadyProcessed) {
			highlight_index(position, false);
		}
	};
	
	function next_or_previous_change(step) {
		disable_highlight_on_previous();

		const first = 0;
		const last =  all_changes.length - 1;
		
		if (position === null) {
			if (step < 0) {
				position = last;
			} else if (step > 0) {
				position = first;
			}
		} else {
			position += step;
		}
		
		if (position >= all_changes.length) {
			position = first;
		} else if (position < 0) {
			position = last;
		}
		highlight_index();
	}
	
	
	set_hash(window.location.hash);
	
	window.addEventListener("load", function () {
		const active_change = window.location.hash.match(/change-(?<id>[0-9]+)/);
		if (active_change) {
			const el = highlight_index(Number(active_change[1]), false);
			//console.log("scrolling there!");
			el.scrollIntoView({behavior: "instant", block: "center", inline: "center" });
		}
		window.setTimeout(() => {
			document.querySelector("html").style["scroll-behavior"] = "smooth";
		}, 500);
	});
	
	window.addEventListener("keydown", function (e) {
		if ((e.altKey) && e.code == "ArrowRight") {
			next_or_previous_change(1);
		} else if (position != null && e.code == "ArrowRight") {
			next_or_previous_change(1);
		} else if ((e.altKey) && e.code == "ArrowLeft") {
			next_or_previous_change(-1);
		} else if (position != null && e.code == "ArrowLeft") {
			next_or_previous_change(-1);
		} else if ((e.altKey) && e.code == "KeyF") {
			document.documentElement.requestFullscreen();
		}
	});
	
	const hide_button = document.getElementById("hide");
	hide_button.onclick = (e) => {
		if (hide_button.classList.contains("enabled")) {
			hide_button.classList.remove("enabled");
		} else {
			hide_button.classList.add("enabled");
		}
	};
	
	function navigate(e, elem) {
		//e.preventDefault();
		//return true;
		const target = elem.getAttribute("href");
		history.pushState(null, null, target);
		const target_element = document.getElementById(target.substr(1));
	}
	
	window.setTimeout(() => document.querySelector("article").classList.add("transitionable"), 500);
	
	document.querySelectorAll("a[href^=\"#\"]").forEach((elem) => { elem.onclick = (e) => navigate(e, elem); } );
	
	function send_email(link) {
		const [prefix, encoded] = link.getAttribute("href").split("#",2);
		window.location = "mailto:"+window.atob(encoded);
		return false;
	}
	
	document.querySelectorAll("a").forEach(link => {
		const relative = link.getAttribute("href");
		if (relative && !relative.startsWith("#") && !relative.startsWith("http://") && !relative.startsWith("https://")) {
			link.href= `https://eel.is/c++draft/${relative}`;
		}
		
	})
	
	const current_url = new URL(window.location.href);
	
	const replace_url_with_current_setting = () => {
    window.history.replaceState({path:current_url.toString()},'', current_url.toString());
	};
	
	const update_poll_dependencies = (poll_id, value) => {
		const selection = document.querySelectorAll(`span.poll_value[x-poll-id="${poll_id}"]`);
		selection.forEach((el) => {
			el.innerText = value;
		});
		
		const discardable = document.querySelectorAll(`.poll_condition[x-poll-id="${poll_id}"]`);
		discardable.forEach((el) => {
			if (el.getAttribute("x-poll-value") == value) {
				el.classList.remove("discard");
			} else {
				el.classList.add("discard");
			}
		});
	}

	const change_poll_dependencies = (poll_id, object) => {
		console.log(`changing poll ${poll_id} dependecies to value ${object.value}`);
		const value = object.value;
		update_poll_dependencies(poll_id, value);
		current_url.searchParams.set(`poll_${poll_id}`, value);
		replace_url_with_current_setting();
	};
	
	
	for (const [key, value] of current_url.searchParams) {
		const m = key.match(/poll_([a-z\-]+)/);
		console.log(`search params = ${key}=${value}`);
		const name = m?.[1];
		if (name) {
			const selection = document.querySelector(`input[type="radio"][name="${name}"][value="${value}"]:not([disabled])`);
			if (selection) {
				update_poll_dependencies(name, value);
				selection.checked = true;
			} else {
				console.error(`poll query variable! ${name}=${value}`);
			}
		}
	}
</script>

<!-- init-hljs.js -->
<script>
// trim must be first, before merge
hljs.addPlugin(trimNicely);
hljs.addPlugin(mergeHTMLPlugin);
hljs.highlightAll();

</script>
</body>
</html>
