45 lines
4.2 KiB
HTML
45 lines
4.2 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::stop_callback<Callback>::~stop_callback</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_stop_callback_stop_callback 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::stop_callback<Callback>::</span>~stop_callback</h1>
|
|
<div id="bodyContent">
|
|
<div id="contentSub"><span class="subpages">< <a href="cpp.html">cpp</a>‎ | <a href="cpp-thread.html">thread</a>‎ | <a href="cpp-thread-stop_callback.html">stop callback</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">~stop_callback<span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td class="t-dcl-nopad"></td>
|
|
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl-sep">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>销毁 <code>stop_callback</code> 对象。</p>
|
|
<p>若 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">*</span>this</span></span> 拥有带关联停止状态的 <code>stop_token</code> ,则从它解除注册。</p>
|
|
<p>若同时在另一县城上调用回调函数,则析构函数直至回调函数调用为止都不会完成。若在调用析构函数的同一线程上正在调用回调函数,则析构函数会不等待回调调用完成就返回(见注解)。</p>
|
|
<h3><span class="mw-headline" id=".E6.B3.A8.E8.A7.A3">注解</span></h3>
|
|
<p><code>stop_callback</code> 析构函数被设计为阻止竞争条件与死锁。若另一线程同时调用回调,则析构函数不能返回直至它完成,否则函数对象能潜在地在执行时被销毁。不要求回调函数自身既不可复制亦不可移动————它在注册后就生存于 <code>stop_callback</code> 对象自身中。</p>
|
|
<p>另一方面,若调用析构函数的当前线程是与调用回调相同的线程,则析构函数不能等待,否则会出现死锁。同一线程在调用 <code>stop_callback</code> 的回调函数时析构它是可能且合法的,因为回调函数自身可能直接或间接销毁 <code>stop_callback</code> 。</p>
|
|
</div>
|
|
<div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|