-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Labels
Description
The documentation page on when_all has this to say:
This function create a joining future. When all passed
argsfutures are fulfilled, then the continuation tasks defined withfis scheduled on the executore.
It even describes the parameter e as "Executor which is used to schedule the resulting task".
That would lead me to believe that the following test cases should pass:
BOOST_FIXTURE_TEST_SUITE(future_when_all_scheduling, test_fixture<void>)
BOOST_AUTO_TEST_CASE(future_when_all_args)
{
auto f1 = make_ready_future(custom_scheduler<0>());
auto f2 = make_ready_future(custom_scheduler<0>());
sut = when_all(custom_scheduler<1>(), []{}, f1, f2);
wait_until_future_completed(sut);
BOOST_REQUIRE_LE(1, custom_scheduler<1>::usage_counter());
}
BOOST_AUTO_TEST_CASE(future_when_all_range)
{
future<void> fs[] = { make_ready_future(custom_scheduler<0>()), make_ready_future(custom_scheduler<0>()) };
sut = when_all(custom_scheduler<1>(), []{}, std::pair{ std::begin(fs), std::end(fs) });
wait_until_future_completed(sut);
BOOST_REQUIRE_LE(1, custom_scheduler<1>::usage_counter());
}
BOOST_AUTO_TEST_SUITE_END()However, in both cases, custom_scheduler<1>::usage_counter() is 0. The continuation appears to always run immediately as part of the last future becoming ready; it isn't even scheduled on custom_scheduler<0>. To me, this is surprising behavior.