Boost C++ Libraries: Ticket #4710: c++11 compliance: : Missing async() https://svn.boost.org/trac10/ticket/4710 <p> The lack of an <code>async()</code> call makes futures awfully cumbersome to use. I hacked up this nullary prototype for C++03. It's better than nothing! </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/thread.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/utility/result_of.hpp&gt;</span><span class="cp"></span> <span class="k">template</span> <span class="o">&lt;</span><span class="k">class</span> <span class="nc">F</span><span class="o">&gt;</span> <span class="n">boost</span><span class="o">::</span><span class="n">detail</span><span class="o">::</span><span class="n">thread_move_t</span><span class="o">&lt;</span><span class="n">boost</span><span class="o">::</span><span class="n">unique_future</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">boost</span><span class="o">::</span><span class="n">result_of</span><span class="o">&lt;</span><span class="n">F</span><span class="p">()</span><span class="o">&gt;::</span><span class="n">type</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">async</span><span class="p">(</span><span class="n">F</span> <span class="n">f</span><span class="p">)</span> <span class="p">{</span> <span class="k">typedef</span> <span class="k">typename</span> <span class="n">boost</span><span class="o">::</span><span class="n">result_of</span><span class="o">&lt;</span><span class="n">F</span><span class="p">()</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">R</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">packaged_task</span><span class="o">&lt;</span><span class="n">R</span><span class="o">&gt;</span> <span class="n">pt</span><span class="p">(</span> <span class="n">f</span> <span class="p">);</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">unique_future</span><span class="o">&lt;</span><span class="n">R</span><span class="o">&gt;</span> <span class="n">future</span><span class="p">;</span> <span class="n">future</span> <span class="n">ret</span> <span class="o">=</span> <span class="n">pt</span><span class="p">.</span><span class="n">get_future</span><span class="p">();</span> <span class="n">boost</span><span class="o">::</span><span class="kr">thread</span><span class="p">(</span> <span class="n">boost</span><span class="o">::</span><span class="n">move</span><span class="p">(</span><span class="n">pt</span><span class="p">)</span> <span class="p">).</span><span class="n">detach</span><span class="p">();</span> <span class="k">return</span> <span class="n">boost</span><span class="o">::</span><span class="n">move</span><span class="p">(</span><span class="n">ret</span><span class="p">);</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4710 Trac 1.4.3 viboes Sat, 27 Nov 2010 16:55:57 GMT type, component changed https://svn.boost.org/trac10/ticket/4710#comment:1 https://svn.boost.org/trac10/ticket/4710#comment:1 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> <li><strong>component</strong> <span class="trac-field-old">threads</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Fri, 02 Dec 2011 05:37:58 GMT cc, keywords set https://svn.boost.org/trac10/ticket/4710#comment:2 https://svn.boost.org/trac10/ticket/4710#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> <li><strong>keywords</strong> async standard added </li> </ul> Ticket anonymous Thu, 15 Dec 2011 16:57:58 GMT summary changed https://svn.boost.org/trac10/ticket/4710#comment:3 https://svn.boost.org/trac10/ticket/4710#comment:3 <ul> <li><strong>summary</strong> <span class="trac-field-old">Missing async()</span> → <span class="trac-field-new">c++11 complicance: : Missing async()</span> </li> </ul> Ticket viboes Thu, 15 Dec 2011 17:01:12 GMT summary changed https://svn.boost.org/trac10/ticket/4710#comment:4 https://svn.boost.org/trac10/ticket/4710#comment:4 <ul> <li><strong>summary</strong> <span class="trac-field-old">c++11 complicance: : Missing async()</span> → <span class="trac-field-new">c++11 compliance: : Missing async()</span> </li> </ul> Ticket viboes Thu, 05 Jan 2012 05:50:55 GMT owner, status changed https://svn.boost.org/trac10/ticket/4710#comment:5 https://svn.boost.org/trac10/ticket/4710#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket viboes Sat, 18 Aug 2012 14:44:19 GMT milestone changed https://svn.boost.org/trac10/ticket/4710#comment:6 https://svn.boost.org/trac10/ticket/4710#comment:6 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.52.0</span> </li> </ul> Ticket viboes Sat, 25 Aug 2012 10:59:35 GMT <link>https://svn.boost.org/trac10/ticket/4710#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4710#comment:7</guid> <description> <p> Add </p> <pre class="wiki">template &lt;class F, class... Args&gt; future&lt;typename result_of&lt;F(Args...)&gt;::type&gt; async(F&amp;&amp; f, Args&amp;&amp;... args); template &lt;class F, class... Args&gt; future&lt;typename result_of&lt;F(Args...)&gt;::type&gt; async(launch policy, F&amp;&amp; f, Args&amp;&amp;... args); </pre><p> to conform with c++11. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 09 Sep 2012 13:11:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4710#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4710#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4710#comment:7" title="Comment 7">viboes</a>: </p> <blockquote class="citation"> <p> Add </p> <pre class="wiki">template &lt;class F, class... Args&gt; future&lt;typename result_of&lt;F(Args...)&gt;::type&gt; async(F&amp;&amp; f, Args&amp;&amp;... args); template &lt;class F, class... Args&gt; future&lt;typename result_of&lt;F(Args...)&gt;::type&gt; async(launch policy, F&amp;&amp; f, Args&amp;&amp;... args); </pre><p> to conform with c++11. </p> </blockquote> <p> I will implement these prototypes later on. </p> <p> For the time been, the minimal request has benn done. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 09 Sep 2012 13:12:05 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4710#comment:9 https://svn.boost.org/trac10/ticket/4710#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Merged from trunk <a class="changeset" href="https://svn.boost.org/trac10/changeset/80450" title="Thread: merge from trunk: 1.52">[80450]</a>. </p> Ticket