safechan

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SafeChannel

type SafeChannel[T any] struct {
	// contains filtered or unexported fields
}

SafeChannel can send or be closed safely. Do not close the inner channel directly.

func NewSafeChannel

func NewSafeChannel[T any]() *SafeChannel[T]

func (*SafeChannel[T]) OutCh

func (c *SafeChannel[T]) OutCh() <-chan T

OutCh returns a native read-only channel.

func (*SafeChannel[T]) SafeClose

func (c *SafeChannel[T]) SafeClose()

func (*SafeChannel[T]) SafeSend

func (c *SafeChannel[T]) SafeSend(value T) (ok bool)

SafeSend sends given value safely which means there's no panic even if channel is closed. Return false if it has been closed.

Jump to

Keyboard shortcuts

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