folly::channels::merge

Merge takes a list of receivers, and returns a new receiver that receives all updates from all input receivers. If any input receiver closes with an exception, the exception is forwarded and the channel is closed. If any input receiver closes without an exception, the channel continues to merge values from the other input receivers until all input receivers are closed.

Synopsis

Declared in <folly/channels/Merge.h>

template<
    typename TReceiver,
    typename TValue = TReceiver::ValueType>
Receiver<TValue>
merge(
    std::vector<TReceiver> inputReceivers,
    folly::Executor::KeepAlive<folly::SequencedExecutor> executor,
    bool waitForAllInputsToClose = true);

Description

Example:

// Example function that returns a list of receivers std::vector<Receiver<int>> getReceivers();

// Example function that returns an executor folly::Executor::KeepAlive<folly::SequencedExecutor> getExecutor();

Receiver<int> mergedReceiver = merge(getReceivers(), getExecutor());

Return Value

A receiver that yields all values from every input receiver.

Parameters

NameDescription
inputReceiversThe collection of input receivers to merge.
executorA SequencedExecutor used to merge input values.
waitForAllInputsToCloseWhen true, if any input receiver closes without an exception, the channel continues to merge values from the other input receivers until all input receivers are closed. If false, the channel closes as soon as any input receiver has closed.