Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrOutputClosed = errors.New("output channel closed")
Functions ¶
This section is empty.
Types ¶
type FanIn ¶ added in v0.9.0
type FanIn[T any] struct { // contains filtered or unexported fields }
FanIn is a fan-in channel multiplexer. It takes multiple input channels and merges them into a single output channel. The Implementation is thread-safe.
func (*FanIn[T]) Add ¶ added in v0.9.0
Add adds a new input channel. If the output channel is already closed, the error is returned.
func (*FanIn[T]) AutoClose ¶ added in v0.9.0
func (fi *FanIn[T]) AutoClose()
AutoClose will automatically close the output channel when all input channels are closed. This method must be called only after at least one input channel has been added. Otherwise, it will immediately close the output channel. This method is idempotent and non-blocking.
func (*FanIn[T]) Chan ¶ added in v0.9.0
func (fi *FanIn[T]) Chan() <-chan T
Chan returns the output channel.
func (*FanIn[T]) Close ¶ added in v0.9.0
Close closes the output channel. If the output channel is already closed, the error is returned. This method must be called only after all input channels are closed. Otherwise, the code may panic due to sending to a closed channel. To make sure that all input channels are closed, a call to this method can be preceded by a call to the Wait method. Alternatively, the AutoClose method can be used.
type FanOut ¶ added in v0.9.0
type FanOut[T any] struct { // contains filtered or unexported fields }
FanOut is a fan-out channel demultiplexer. It takes a single input channel and distributes its values to multiple output channels. The input channel is emptied even if there are no output channels. Output channels are closed when the input channel is closed. The implementation is thread-safe.