concurrency.operations.toshared

Undocumented in source.

Members

Classes

SharedSender
class SharedSender(Sender, Scheduler, ResetLogic resetLogic)
Undocumented in source.

Enums

ResetLogic
enum ResetLogic
Undocumented in source.

Functions

toShared
auto toShared(Sender sender, Scheduler scheduler)

Wraps a Sender in a SharedSender. A SharedSender allows many receivers to connect to the same underlying Sender, forwarding the same termination call to each receiver. The underlying Sender is connected and started only once. It can be explicitely reset so that it connects and starts the underlying Sender the next time it started. Calling reset when the underlying Sender hasn't completed is a no-op. When the last receiver triggers its stoptoken while the underlying Sender is still running, the latter will be cancelled and one termination function of the former will be called after the latter is completed. (This is to ensure structured concurrency, otherwise tasks could be left running without anyone awaiting them). If an receiver is connected after the underlying Sender has already been completed, that receiver will have one of its termination functions called immediately. This operation is useful when you have multiple tasks that all depend on one shared task. It allows you to write the shared task as a regular Sender and simply apply a .toShared.

toShared
auto toShared(Sender sender)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta