<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Future on 111qqz's blog</title><link>https://111qqz.com/en/tags/future/</link><description>Recent content in Future on 111qqz's blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2015-2026 111qqz</copyright><lastBuildDate>Sun, 30 Sep 2018 06:49:27 +0000</lastBuildDate><atom:link href="https://111qqz.com/en/tags/future/index.xml" rel="self" type="application/rss+xml"/><item><title>[c++11] std::async std::packaged_task std::promise and std::future notes</title><link>https://111qqz.com/en/post/%E5%B7%A5%E7%A8%8B/cpp/2018-09-30-async-packaged-ask-promise-future-notes/</link><pubDate>Sun, 30 Sep 2018 06:49:27 +0000</pubDate><guid>https://111qqz.com/en/post/%E5%B7%A5%E7%A8%8B/cpp/2018-09-30-async-packaged-ask-promise-future-notes/</guid><description>&lt;p&gt;把std::async,std::packaged_task,std::promise三个放在一起来说,是因为他们都可以返回一个std::future对象.简单来说,当某个线程需要等待一个特定的一次性事件(one-off event),它可以用一个&amp;quot;future&amp;quot;来表示这个事件.&lt;/p&gt;</description></item><item><title>[C++11] promise &amp;&amp; future leanrning notes</title><link>https://111qqz.com/en/post/%E5%B7%A5%E7%A8%8B/cpp/2018-08-23-c11-promise-future-notes/</link><pubDate>Thu, 23 Aug 2018 02:45:53 +0000</pubDate><guid>https://111qqz.com/en/post/%E5%B7%A5%E7%A8%8B/cpp/2018-08-23-c11-promise-future-notes/</guid><description>&lt;figure&gt;&lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt="std::promise / std::future（根据正文上下文重绘的示例图，并非遗失原图）"
 src="https://111qqz.com/images/generated/missing/026-promise-future.svg"
 &gt;&lt;/figure&gt;
&lt;p&gt;用人话就是，主线程传给附属线程一个promise Object,然后主线程想要获取附属线程set给promise Object的值（也就是该线程返回的某个结果），需要通过主线程中的promise object 得到对应的future object(每个promise 对应一个 future),然后调用future 的get方法。如果附属线程没有执行作为参数传入的promise的set方法去返回结果，那么程序就会block住。&lt;/p&gt;</description></item></channel></rss>