TEST_F(ShardServerTestFixture, ShutdownExecutorDoesNotKillWaitOnFuture){
|
const std::string kExecName("CoolExecName");
|
auto net = executor::makeNetworkInterface(kExecName);
|
auto pool = std::make_unique<executor::NetworkInterfaceThreadPool>(net.get());
|
auto taskExecutor =
|
std::make_shared<executor::ThreadPoolTaskExecutor>(std::move(pool), std::move(net));
|
taskExecutor->startup();
|
|
SharedPromise<void> promise;
|
|
auto chainCompletion = ExecutorFuture<void>(taskExecutor)
|
.then([futureToWaitOn = promise.getFuture()](){
|
return futureToWaitOn; // Wait for the future to be marked as ready
|
}).share();
|
|
// Sleep a bit before shutting down the executor to make sure the chain arrives to `return futureToWaitOn;`
|
sleep(2);
|
|
taskExecutor->shutdown();
|
|
// The following line hangs forever (as long as `futureToWaitOn` is not ready) because the wait is not killed on executor shutdown
|
chainCompletion.getNoThrow().ignore();
|
}
|