channel

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: MIT Imports: 1 Imported by: 0

README

Safe Channel

The library tries to remove some dangerous behaviors on normal channel:

  • Write on a closed channel
  • Close a closed channel

These above operations will be silently discarded.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

Channel wraps the built-in channel and provide safe operations beyond it

func New

func New() *Channel

New creates a new Channel

func NewBufferedChannel

func NewBufferedChannel(n int) *Channel

NewBufferedChannel creates a buffered Channel

func (*Channel) Close

func (c *Channel) Close()

Close closes an active channel This method can be called many times without risks

func (*Channel) Publish

func (c *Channel) Publish(x interface{})

Publish sends an event to channel If channel is closed, Publish does nothing

func (*Channel) Watch

func (c *Channel) Watch() <-chan interface{}

Watch keeps listening on a channel

Jump to

Keyboard shortcuts

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