Files
hustoj/web/cppreference-zh/chmhelp/cpp-thread-counting_semaphore-counting_semaphore.html
2025-08-01 12:57:54 +08:00

60 lines
3.5 KiB
HTML

<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">
<head><meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>std::counting_semaphore&lt;LeastMaxValue&gt;::counting_semaphore</title>
<link rel="stylesheet" href="ext.css" />
<link rel="stylesheet" href="site_modules.css" />
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_thread_counting_semaphore_counting_semaphore skin-cppreference2 action-view cpp-navbar">
<div id="cpp-content-base">
<div id="content"><a id="top"></a>
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::counting_semaphore&lt;LeastMaxValue&gt;::</span>counting_semaphore</h1>
<div id="bodyContent">
<div id="contentSub"><span class="subpages">&lt; <a href="cpp.html">cpp</a>&lrm; | <a href="cpp-thread.html">thread</a>&lrm; | <a href="cpp-thread-counting_semaphore.html">counting semaphore</a></span></div>
<div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr" xml:lang="zh">
<table class="t-dcl-begin">
<tbody>
<tr class="t-dcl t-since-cxx20">
<td>
<div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw1">explicit</span> counting_semaphore<span class="br0">(</span> <a href="cpp-types-ptrdiff_t.html"><span class="kw101">std::<span class="me2">ptrdiff_t</span></span></a> desired <span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td>(1)</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx20">
<td>
<div><span class="mw-geshi cpp source-cpp">counting_semaphore<span class="br0">(</span> <span class="kw4">const</span> counting_semaphore<span class="sy3">&amp;</span> <span class="br0">)</span> <span class="sy1">=</span> delete<span class="sy4">;</span></span></div>
</td>
<td>(2)</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 &#36215;)</span></td>
</tr>
<tr class="t-dcl-sep">
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<div class="t-li1"><span class="t-li">1)</span> &#26500;&#36896;&#19968;&#20010; <code>std::counting_semaphore</code> &#31867;&#22411;&#23545;&#35937;&#65292;&#21021;&#22987;&#21270;&#20854;&#35745;&#25968;&#22120;&#30340;&#20540;&#20026; <code>desired</code> &#12290;</div>
<div class="t-li1"><span class="t-li">2)</span> &#22797;&#21046;&#26500;&#36896;&#20989;&#25968;&#34987;&#21024;&#38500;&#12290;</div>
<h3><span class="mw-headline" id=".E5.89.8D.E6.9D.A1.E4.BB.B6">&#21069;&#26465;&#20214;</span></h3>
<div class="t-li1"><span class="t-li">1)</span> <span class="t-c"><span class="mw-geshi cpp source-cpp">desired <span class="sy1">&gt;=</span> <span class="nu0">0</span></span></span> &#19982; <span class="t-c"><span class="mw-geshi cpp source-cpp">desired <span class="sy1">&lt;=</span> max<span class="br0">(</span><span class="br0">)</span></span></span> &#22343;&#20026; <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">true</span></span></span> &#12290;</div>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">&#21442;&#25968;</span></h3>
<table class="t-par-begin">
<tr class="t-par">
<td>desired</td>
<td>-</td>
<td>&#29992;&#20110;&#21021;&#22987;&#21270; <code>counting_semaphore</code> &#30340;&#35745;&#25968;&#22120;&#30340;&#20540;</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8">&#24322;&#24120;</span></h3>
<p>&#19981;&#25243;&#20986;&#12290;</p>
</div>
<div class="visualClear"></div>
</div>
</div>
</div>
</body>
</html>