channel

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MPL-2.0 Imports: 1 Imported by: 12

Documentation

Overview

Package channel provides generic operations on channels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendWithContext

func SendWithContext[T any](ctx context.Context, ch chan<- T, val T) bool

SendWithContext tries to send a value to a channel which is aborted if the context is canceled.

Function returns true if the value was sent, false if the context was canceled.

Types

type RecvState added in v0.4.4

type RecvState int

RecvState is the state of a channel after receiving a value.

const (
	// StateRecv means that a value was received from the channel.
	StateRecv RecvState = iota
	// StateEmpty means that the channel was empty.
	StateEmpty
	// StateClosed means that the channel was closed.
	StateClosed
)

func TryRecv added in v0.4.4

func TryRecv[T any](ch <-chan T) (T, RecvState)

TryRecv tries to receive a value from a channel.

Function returns the value and the state of the channel.

Jump to

Keyboard shortcuts

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