Opened 7 years ago
Closed 7 years ago
#11818 closed Bugs (fixed)
future.then will be blocked if promise is set after the invocation of then
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.60.0 | Component: | thread |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | Cc: |
Description (last modified by )
int function() { boost::promise<int> promise; boost::future<int> future = promise.get_future(); boost::future<int> result = future.then ( boost::launch::deferred, [](boost::future<int> && f) { std::cout << std::this_thread::get_id() << ": callback" << std::endl; std::cout << "The value is: " << f.get() << std::endl; return f.get(); } ); // We could not reach here. std::cout << std::this_thread::get_id() << ": function" << std::endl; promise.set_value(0); return 0; }
Change History (5)
comment:1 by , 7 years ago
Summary: | future.then will be blocked if promise is set after then invocation of then → future.then will be blocked if promise is set after the invocation of then |
---|
comment:2 by , 7 years ago
Description: | modified (diff) |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 7 years ago
I believe this is a bug.
When you launch the continuation with deferred policy, the continuation shouldn't be executed until a call to result.get() is done.
Actually the future.then(launch::deferred, f) do a call to future.wait() and so it blocks.
I will try to fix it for the next release, but the release is upcoming :(
comment:4 by , 7 years ago
Milestone: | To Be Determined → Boost 1.60.0 |
---|
comment:5 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.