Subject: [Boost-bugs] [Boost C++ Libraries] #8955: Request for more efficient way to get exception_ptr from future
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-01 23:38:49
#8955: Request for more efficient way to get exception_ptr from future
------------------------------+--------------------------
Reporter: ned14 | Owner: anthonyw
Type: Feature Requests | Status: new
Milestone: Boost 1.55.0 | Component: thread
Version: Boost 1.54.0 | Severity: Optimization
Keywords: |
------------------------------+--------------------------
Vicente,
Here is that Boost.Thread feature request for AFIO I mentioned a while
ago. Here is the code example:
{{{
shared_future<std::shared_ptr<detail::async_io_handle>>
*thisresult=state.first->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->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);
}}}
Taken from
https://github.com/BoostGSoC/boost.afio/blob/master/libs/afio/src/afio.cpp#L1027
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.
In other words, a very simple new feature, but one which lets us eliminate
a lot of needless try...catch stanzas.
My thanks in advance Vicente.
Niall
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8955> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC