cchan

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chan

type Chan[T any] chan T

Chan is a channel with utility methods.

func (Chan[T]) Recv

func (c Chan[T]) Recv(ctx context.Context) (T, bool, error)

Recv will try to receive a value from the channel, same as <-c. If the context is canceled before a value is received, it will return the context error.

func (Chan[T]) RecvTimeout

func (c Chan[T]) RecvTimeout(ctx context.Context, timeout time.Duration) (T, bool, error)

RecvTimeout will try to receive a value from the channel, same as <-c. If the context is canceled before a value is received or the timeout is reached, it will return the context error.

func (Chan[T]) Send added in v0.5.1

func (c Chan[T]) Send(ctx context.Context, v T) error

Send will try to send a value to the channel, same as c<-v. If the context is canceled before a value is sent, it will return the context error.

func (Chan[T]) SendTimeout added in v0.5.1

func (c Chan[T]) SendTimeout(ctx context.Context, v T, timeout time.Duration) error

SendTimeout will try to send a value to the channel, same as c<-v. If the context is canceled before a value is sent or the timeout is reached, it will return the context error.

type ChanIn added in v0.5.1

type ChanIn[T any] chan<- T

ChanIn is an input channel with utility methods.

func (ChanIn[T]) Send added in v0.5.1

func (c ChanIn[T]) Send(ctx context.Context, v T) error

Send will try to send a value to the channel, same as c<-v. If the context is canceled before a value is sent, it will return the context error.

func (ChanIn[T]) SendTimeout added in v0.5.1

func (c ChanIn[T]) SendTimeout(ctx context.Context, v T, timeout time.Duration) error

SendTimeout will try to send a value to the channel, same as c<-v. If the context is canceled before a value is sent or the timeout is reached, it will return the context error.

type ChanOut added in v0.5.1

type ChanOut[T any] <-chan T

ChanOut is an output channel with utility methods.

func (ChanOut[T]) Recv added in v0.5.1

func (c ChanOut[T]) Recv(ctx context.Context) (T, bool, error)

Recv will try to receive a value from the channel, same as <-c. If the context is canceled before a value is received, it will return the context error.

func (ChanOut[T]) RecvTimeout added in v0.5.1

func (c ChanOut[T]) RecvTimeout(ctx context.Context, timeout time.Duration) (T, bool, error)

RecvTimeout will try to receive a value from the channel, same as <-c. If the context is canceled before a value is received or the timeout is reached, it will return the context error.

Jump to

Keyboard shortcuts

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