-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gdb 'catch throw' and boost::fibers::broken_promise when moving promises #167
Comments
promise implements move assignmentin terms of move constructor |
Thanks, just tested with gcc-7.2 and looks like it does a way better job at optimizing the promise move gcc-6.3.0 (-O2)
gcc-7.2.0 (-O2)
gcc-7.2.0 (-O2)
|
which version do you use? what happend with the exceptions you have reported? |
I use the latest develop branch. The exceptions are really only visible with gdb catch throw due to promise_base & operator=( promise_base && other) noexcept {
if ( BOOST_LIKELY( this != & other) ) {
obtained_ = other.obtained_;
future_ = std::move( other.future_);
other.obtained_ = false;
}
return * this;
} Or if I just avoid using it altogether and stick with moving promises using move constructor only. |
the move assignment operator is mssing
Otherwise a future constructed from a promise that gets move-assigned another shared-state will wait forever in Suppose following example:
|
Ah, yes ... thanks for pointing this out. I see there is the |
|
I see boost::fibers::promise<int> p1, p2;
auto f = p1.get_future();
p2 = std::move(p1); I face the overhead of temporary future_ object and more importantly std::make_exception_ptr |
Maybe a modification of ~promise_base() could help:
|
gcc-6.3.0 (-O2)
gcc-7.2.0 (-O2)
With this change promise move assignment is ~10x faster with gcc 6 and ~2x faster with gcc 7 :-) |
- in context of #167 - in dtor of promise_base and packaged_task test if shared-state was initialized and a future was constructed from shared_state - call shared_state::owner_destroyed() only if both condition are true
commit pushed, ty |
I am seeing boost::fibers::broken_promise exceptions with gdb
catch throw
whenmoving (std::move) boost::fibers::promise. This is due
std::make_exception_ptr
that getscalled when tmp object goes out of scope in the move assignment operator:
fiber/include/boost/fiber/future/promise.hpp
Lines 70 to 76 in e325cf7
Wouldn't be better to implement the move assignment the same way as the move constructor?
Test cases (test1 - gdb
catch throw
shows broken_promise, test2 - no throws):The text was updated successfully, but these errors were encountered: