因此,在下面的代码中,可以看到基于布尔变量flag。在folly::collect操作中,我们添加或跳过执行std::move(cleanupFuture)操作。
寻找避免folly::collect中冗余代码块的方法
我正在考虑使用folly::Unit,但不确定它如何兼容,因为返回类型的cleanupFuture是一个folly::Future<bool>。
逻辑:
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 */) {});发布于 2022-08-05 22:58:15
旗子?移动(CleanupFuture):愚蠢::制造未来(真)
https://stackoverflow.com/questions/73243564
复制相似问题