[−][src]Function futures_ext::bounded_traversal::bounded_traversal
pub fn bounded_traversal<In, Ins, Out, OutCtx, Unfold, UFut, Fold, FFut>(
scheduled_max: usize,
init: In,
unfold: Unfold,
fold: Fold
) -> impl Future<Item = Out, Error = UFut::Error> where
Unfold: FnMut(In) -> UFut,
UFut: IntoFuture<Item = (OutCtx, Ins)>,
Ins: IntoIterator<Item = In>,
Fold: FnMut(OutCtx, Iter<Out>) -> FFut,
FFut: IntoFuture<Item = Out, Error = UFut::Error>,
bounded_traversal
traverses implicit asynchronous tree specified by init
and unfold
arguments, and it also does backward pass with fold
operation.
All unfold
and fold
operations are executed in parallel if they do not
depend on each other (not related by ancestor-descendant relation in implicit tree)
with amount of concurrency constrained by scheduled_max
.
init: In
Is the root of the implicit tree to be traversed
unfold: FnMut(In) -> impl IntoFuture<Item = (OutCtx, impl IntoIterator<Item = In>)>
Asynchronous function which given input value produces list of its children. And context
associated with current node. If this list is empty, it is a leaf of the tree, and fold
will be run on this node.
fold: FnMut(OutCtx, impl Iterator<Out>) -> impl IntoFuture<Item=Out>
Aynchronous function which given node context and output of fold
for its chidlren
should produce new output value.
return value impl Future<Item = Out>
Result of running fold operation on the root of the tree.