channel

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ErrTimeout = lerr.Str("timeout")

Variables

View Source
var (
	MaxDelayMS    uint = 1
	SingleDelayUS uint = 10
)

Functions

func Slice

func Slice[T any](s []T, ch chan<- T) (out chan T)

func Timeout

func Timeout[T any](ms int, ch <-chan T) (t T, err error)

Types

type Close

type Close struct {

	// OnClose will block until Close is closed
	OnClose chan Close
	// contains filtered or unexported fields
}

func NewClose

func NewClose() *Close

func (*Close) Close

func (c *Close) Close() bool

func (*Close) Closed

func (c *Close) Closed() bool

type Closed

type Closed struct{}

Closed is a flag.

type Merge

type Merge[T any] struct {
	MaxDelayMS    uint
	SingleDelayUS uint
	// contains filtered or unexported fields
}

func NewMerge

func NewMerge[T any](rcv <-chan []T, snd chan<- []T) (m *Merge[T], retSnd chan<- []T, retRcv <-chan []T)

func (*Merge[T]) Cycle

func (m *Merge[T]) Cycle(buf []T)

Cycle receives on In and combines all the slices it recevies and sends them to Out. It will receive for a maximum of MaxDelayMS or if it goes SingleDelayUS without receiving anything.

func (*Merge[T]) Run

func (m *Merge[T]) Run()

Run invokes Cycle everytime data is received on In. This adds at least SingleDelayUS latentcy.

type Pipe

type Pipe[T any] struct {
	Rcv <-chan T
	Snd chan<- T
}

Pipe holds a pair of channels. It is intended for embedding.

func NewPipe

func NewPipe[T any](rcv <-chan T, snd chan<- T) (pipe Pipe[T], retSnd chan<- T, retRcv <-chan T)

type Writer

type Writer struct {
	Ch chan<- []byte
}

func (Writer) Write

func (w Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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