Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11256: future<>::is_ready() == false in continuation function
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-02 19:10:29
#11256: future<>::is_ready() == false in continuation function
-------------------------------------+-------------------------------------
Reporter: Konrad Zemek | Owner: viboes
<konrad.zemek@â¦> | Status: assigned
Type: Bugs | Component: thread
Milestone: To Be Determined | Severity: Problem
Version: Boost 1.58.0 | Keywords: then continuation
Resolution: | is_ready
-------------------------------------+-------------------------------------
Comment (by Konrad Zemek <konrad.zemek@â¦>):
Below is the simplest code I got to reproduce if anyone else is curious.
This version fails on assert, but when you remove {{{.unwrap()}}} it
deadlocks instead (in this particular version, {{{boost::lock}}} throws
exception saying "resource deadlock avoided", but my other code just
deadlocks).
{{{#!c++
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
#include <boost/thread.hpp>
#include <boost/thread/thread_pool.hpp>
#include <cassert>
auto createFuture()
{
boost::promise<void> promise;
promise.set_value();
return promise.get_future();
}
auto stepOne(boost::basic_thread_pool &executor)
{
auto sendFuture = createFuture();
auto wrappedFuture = sendFuture.then(executor, [](auto f) mutable {
return createFuture();
});
return wrappedFuture.unwrap();
}
auto stepTwo(boost::basic_thread_pool &executor)
{
auto future = stepOne(executor);
return future.then(executor, [](auto f) {
assert(f.is_ready());
});
}
int main()
{
boost::basic_thread_pool executor{1};
stepTwo(executor).get();
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11256#comment:4> 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:18 UTC