Boost C++ Libraries: Ticket #8955: Request for more efficient way to get exception_ptr from future https://svn.boost.org/trac10/ticket/8955 <p> Vicente, </p> <p> Here is that Boost.Thread feature request for AFIO I mentioned a while ago. Here is the code example: </p> <pre class="wiki"> shared_future&lt;std::shared_ptr&lt;detail::async_io_handle&gt;&gt; *thisresult=state.first-&gt;outsharedstates[idx].get(); // This seems excessive but I don't see any other legal way to extract the exception ... bool success=false; try { // Always must wait on the others, because some may be between decrementing the // atomic and returning their result to here. Any waiting is likely short. thisresult-&gt;get(); success=true; } catch(...) { exception_ptr e(afio::make_exception_ptr(afio::current_exception())); assert(e); complete_async_op(s.out[idx].first, s.out[idx].second, e); } if(success) complete_async_op(s.out[idx].first, s.out[idx].second); </pre><p> Taken from <a class="ext-link" href="https://github.com/BoostGSoC/boost.afio/blob/master/libs/afio/src/afio.cpp#L1027"><span class="icon">​</span>https://github.com/BoostGSoC/boost.afio/blob/master/libs/afio/src/afio.cpp#L1027</a> </p> <p> Basically, we need to scan a sequence of futures for any exception states which right now means trying to get() from each and try...catch to grab any exception_ptr's. As this is inefficient, is there any chance of adding a new member function to future and shared_future: get_exception()? This is identical to get(), except it returns any exception state instead of throwing it. If there is no exception state, it returns a null exception_ptr. </p> <p> In other words, a very simple new feature, but one which lets us eliminate a lot of needless try...catch stanzas. </p> <p> My thanks in advance Vicente. </p> <p> Niall </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8955 Trac 1.4.3 viboes Sat, 03 Aug 2013 04:51:47 GMT owner, status, milestone changed https://svn.boost.org/trac10/ticket/8955#comment:1 https://svn.boost.org/trac10/ticket/8955#comment:1 <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> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.55.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket viboes Tue, 10 Sep 2013 19:40:35 GMT milestone changed https://svn.boost.org/trac10/ticket/8955#comment:2 https://svn.boost.org/trac10/ticket/8955#comment:2 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85644" title="Thread: added future&lt;&gt;::get_exception_ptr().">[85644]</a>. </p> Ticket viboes Sat, 14 Sep 2013 14:23:38 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8955#comment:3 https://svn.boost.org/trac10/ticket/8955#comment:3 <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> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85666" title="Thread: merge atomic linked conditionaly + future:get_exception_ptr.">[85666]</a>. </p> Ticket