#11231 closed Feature Requests (fixed)
Allow to set continuation future's destructor behavior to non-blocking
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.60.0 | Component: | thread |
Version: | Boost 1.58.0 | Severity: | Not Applicable |
Keywords: | Cc: |
Description
As discussed on the mailing list:
Currently, continuation futures created using future<>::then()
with boost::launch::async
or an executor block on destruction (until the value is ready).
I would like there to be a way to disable this behavior, whether through an additional argument in future<>::then()
(much like boost::defer_lock
in locks' constructors), a method explicitly setting the non-blocking behavior, or implicitly through a call to future<>::wait_for/until()
.
Change History (5)
comment:1 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 7 years ago
Milestone: | To Be Determined → Boost 1.60.0 |
---|
comment:3 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
4321b59c1eedde71da58f592aa4c741a1feff046
follow-up: 5 comment:4 by , 7 years ago
The blocking option seems to be broken. Future destructor doesn't block even if BOOST_THREAD_FUTURE_BLOCKING is defined and the futture was obtained by a call to boost::async() with boost::launch::async, or by calling other_future.then().
int main() { { auto future = boost::async(boost::launch::async, []() { std::this_thread::sleep_for(1s); return 42; }); } //future destructor doesn't block //do stuff... //-> will heppen before the future state is ready }
comment:5 by , 6 years ago
Replying to anonymous:
The blocking option seems to be broken. Future destructor doesn't block even if BOOST_THREAD_FUTURE_BLOCKING is defined and the futture was obtained by a call to boost::async() with boost::launch::async, or by calling other_future.then().
int main() { { auto future = boost::async(boost::launch::async, []() { std::this_thread::sleep_for(1s); return 42; }); } //future destructor doesn't block //do stuff... //-> will heppen before the future state is ready }
The future destructor is never called even though the variable 'future' goes out of scope. See ticket #12220 for details.
https://github.com/boostorg/thread/commit/88ab663ac58a2a903ee26b47a4eedb57535c4d14