The effect of this difference in behavior can be observed in the _ComposeSubtree method. With std::optioanl's implementation the `if(_dispatcher)` check returns false and these will not be enqueued to the dispatcher. The result was a significant speed regression due to lack of parallelism.
This fix adds and explict call to WorkDispatcher::Wait() before setting _dispatcher to std::nullopt. This ensures that all tasks are enqueued and will be processed in parallel.
(Internal change:
2308941)
}
}
catch (...) {
+ _dispatcher->Wait();
_dispatcher = std::nullopt;
throw;
}
+ _dispatcher->Wait();
_dispatcher = std::nullopt;
});
}
});
}
}
+ _dispatcher->Wait();
_dispatcher = std::nullopt;
});
}