31 #ifndef LEDGER_CORE_ALGORITHM_H 32 #define LEDGER_CORE_ALGORITHM_H 35 #include <utils/ImmediateExecutionContext.hpp> 44 Future<Unit> sequence_go(
const std::shared_ptr<api::ExecutionContext>& context,
int index,
const std::vector< Future<T> >& futures, std::vector<T>* buffer) {
45 if (index >= futures.size())
46 return Future<Unit>::successful(unit);
48 Future<T> fut = futures[index];
49 return fut.template flatMap<Unit>(context, [context, buffer, index, futures](
const T &r) -> Future<Unit> {
51 return sequence_go(context, index + 1, futures, buffer);
59 Future< std::vector<T> > sequence(
const std::shared_ptr<api::ExecutionContext>& context,
const std::vector< Future<T> >& futures) {
60 auto buffer =
new std::vector<T>();
61 return internals::sequence_go<T>(context, 0, futures, buffer).
template map< std::vector<T> >(context, [buffer] (
const Unit&) -> std::vector<T> {
72 #define BEGIN_ASYNC_WHILE() 74 #define ASYNC_FOREACH() 76 #endif //LEDGER_CORE_ALGORITHM_H Definition: Account.cpp:8