So in the below code it can be observed that based on the Boolean variable flag
. In the folly::collect
operation we add or skip doing the std::move(cleanupFuture)
operation.
Looking a way to avoid redundant code piece of the folly::collect
?
I was thinking of using folly::Unit
but not sure how it would be compatible as return type of cleanupFuture
is a folly::Future<bool>
Logic:
if (flag) {
return folly::collect(
std::move(abortFuture))
.via(folly::CPUExecutor().get())
.thenValue([](auto&& /* unused */) {});
}
return folly::collect(
std::move(cleanupFuture),
std::move(abortFuture))
.via(folly::getGlobalCPUExecutor().get())
.thenValue([](auto&& /* unused */) {});