Concatenate the values from multiple streams into a single stream such that each stream is exhausted before the next one begins.
Synopsis
Declared in <folly/coro/Concat.h>
template<
typename HReference,
typename... TReference,
typename HValue,
typename... TValue>
AsyncGenerator<HReference, HValue>
concat(
AsyncGenerator<HReference, HValue> head,
AsyncGenerator<TReference, TValue>... tail);
Description
The input is a variadic list of AsyncGenerators, where each input has the same Reference and Value types.
The output is a single AsyncGenerator over all of the input generators.
Example: AsyncGenerator<int> stream();
Task<int> consumer() { auto values = concat(stream(), stream(), stream());
int result = 0; while (auto item = co_await values.next()) { result += *item; }
return result; }
Return Value
A single generator yielding the values of every input generator.
Parameters
Name |
Description |
head |
The first generator to consume. |
tail |
The remaining generators, consumed in order after |
Created with MrDocs