3 #include <folly/futures/Future.h>
5 #include <folly/Executor.h>
15 class ValueStream :
public std::enable_shared_from_this<ValueStream<T>>
20 virtual ~ValueStream() {}
27 int forEachSync(
const std::function<
void(
const T&)>& f,
int N,
28 const std::function<
bool(
const T&)>& endCond=
nullptr);
30 ValueStream(
const ValueStream&) =
delete;
31 ValueStream& operator=(
const ValueStream&) =
delete;
33 virtual folly::Future<T> next() = 0;
37 using ValueStreamPtr = std::shared_ptr<ValueStream<T>>;
47 const std::function<
bool(
const T&)>& endCond)
51 while(consumed < max) {
52 auto future = next().wait();
54 ValueType ev = future.value();
55 if(endCond && endCond(ev))