I have the following code compiled with Boost 1.62.
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
#include <chrono>
#include <thread>
#include <boost/thread/future.hpp>
#include <boost/thread/executors/loop_executor.hpp>
using namespace std::literals::chrono_literals;
int main() {
auto start = boost::make_ready_future<int>();
boost::loop_executor ex;
auto a = start.then(ex, [](auto &&) { std::cout << "A"; }).share();
auto b = boost::when_all(a).then(ex, [](auto &&) { std::cout << "B";} );
auto c = boost::when_all(a).then(ex, [](auto &&) { std::cout << "C";} );
auto d = boost::when_all(std::move(b),std::move(c)).then(ex, [](auto &&) { std::cout << "D";} );
while ( ex.try_executing_one() )
std::this_thread::sleep_for(100ms);
d.get();
return 0;
}
This generates 4 problems (A, B, C, D) with a diagonal dependence above them (B and C depend on A, D depends on B and C).
Given the fact that I am using loop_executor, I expected that this code would not spawn a single stream and output either "ABCD" or "ACBD".
Instead, this code might or might not be blocked in d.get()(just reduce the timeout to zero to see it blocked), because each call when_allspawns a new thread, which is used to wait futures.
, when_all .then, .
:
, , when_all ?
, , concurrency TS.