in benchmarks/future_benchmark.cpp [217:245]
folly::SemiFuture<folly::Unit> follyTree(
folly::Executor* exec,
Node* node,
Allocator* allocator,
uint32_t depth,
uint32_t bitset,
uint32_t modulo) {
--depth;
node->setValue(bitset, modulo);
if (!depth) {
node->left = nullptr;
node->right = nullptr;
return folly::Unit{};
}
node->left = allocator->alloc();
node->right = allocator->alloc();
return folly::via(
exec,
[=]() {
return folly::collectAll(
follyTree(exec, node->left, allocator, depth, bitset << 1, modulo),
follyTree(exec, node->right, allocator, depth, bitset << 1 | 1, modulo))
.unit();
})
.semi();
}