A FanoutSender allows fanning out updates to multiple output receivers. Values can be written as with a normal Sender. When there is only one output receiver, the memory used by a FanoutSender (and the corresponding output receiver) is the same as the memory used by a normal channel.

Synopsis

Declared in <folly/channels/FanoutSender.h>

template<typename ValueType>
class FanoutSender;

Description

When a new output receiver is added, an optional vector of initial values can be provided. These initial values will only be sent to the new receiver.

Memory used by closed receivers is reclaimed lazily (when iterating over receivers).

Example:

FanoutSender<int> fanoutSender; auto receiver1 = fanoutSender.subscribe(); auto receiver2 = fanoutSender.subscribe(); auto receiver3 = fanoutSender.subscribe({1, 2, 3}); std::move(fanoutSender).close();

Member Functions

Name

Description

FanoutSender [constructor]

Constructors

~FanoutSender [destructor]

Destroys the fanout sender, closing it if still open.

operator=

Move‐assigns a fanout sender, transferring ownership.

anySubscribers

Returns whether this fanout sender has any active output receivers.

close

Closes the fanout sender.

numSubscribers

Returns the number of output receivers for this fanout sender.

subscribe

subscribe overloads

write

Sends the given value to all corresponding receivers.

Created with MrDocs