chans

package
v0.0.0-...-e67b028 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accumulate

func Accumulate[T any](c <-chan T) chan []T

Accumulates the content of a channel into an array

func Broadcast

func Broadcast[T any](c <-chan T, aggresive bool, outs ...chan<- T)

Broadcasts a message to a list of channe. If aggresive is set to true all output channels are guarenteed to receive every item sent, otherwise it will do its best

func Fork

func Fork[T any](handler func() (T, error)) (out chan T, e chan error)

Runs a function in a goroutine and returns the result type and error as channels, saves the boiler plate

func GiantChan

func GiantChan[T any](in <-chan T, out chan<- T, limit uint64) (count *uint64)

func Merge

func Merge[T any](chans ...<-chan T) chan T

Merges multiple channels into one channel

func Sort

func Sort[T any](c <-chan SortItem[T], limit int) (out chan T, overflow chan SortItem[T])

Buffers items from a channel into memory and ensures that the items are sent in order. If limit > 0 and too many items were buffered than the next item will leak into the overflow channel.

func Split

func Split[T any](c <-chan T, outs ...chan<- T)

Splits the output of one channel into multiple channels, guarentees

Types

type SortItem

type SortItem[T any] struct {
	Value T
	Index int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL