chanutil

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidArgs = errors.New("invalid arguments")
)

Functions

func Get

func Get(id ChanID) chan interface{}

Call on the default Chanmap

func Remove

func Remove(id ChanID)

Call on the default Chanmap

Types

type ChanID

type ChanID int64

Chan id.

func New

func New() (id ChanID, c chan interface{})

Call on the default Chanmap

func NewF

func NewF(size int) (id ChanID, c chan interface{})

Call on the default Chanmap

type Chanmap

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

Chanmap can create and index chans. Every chan created by chanmap has a unique id, so you can get them by the id.

Multiple goroutines can invoke methods on a Chanmap simultaneously.

func NewChanmap

func NewChanmap(defChanSize int) *Chanmap

func (*Chanmap) Get

func (m *Chanmap) Get(id ChanID) chan interface{}

func (*Chanmap) New

func (m *Chanmap) New() (id ChanID, c chan interface{})

func (*Chanmap) NewF

func (m *Chanmap) NewF(size int) (id ChanID, c chan interface{})

func (*Chanmap) Remove

func (m *Chanmap) Remove(id ChanID)

type DoneChan

type DoneChan chan struct{}

You can notify something done through DoneChan.SetDone().

func NewDoneChan

func NewDoneChan() DoneChan

func (DoneChan) R

func (d DoneChan) R() DoneChanR

func (DoneChan) SetDone

func (d DoneChan) SetDone()

type DoneChanR

type DoneChanR <-chan struct{}

You can determine whether something done through DoneChanR.Done().

func (DoneChanR) Done

func (d DoneChanR) Done() bool

type Event

type Event chan struct{}

Auto reset event.

func NewEvent

func NewEvent() Event

func (Event) R

func (e Event) R() EventR

func (Event) Set

func (e Event) Set()

type EventR

type EventR <-chan struct{}

You can determine whether event setted through EventR.

type Semaphore

type Semaphore chan struct{}

Semaphore can be used to limit access to multiple resources.

func NewSemaphore

func NewSemaphore(n int) Semaphore

func (Semaphore) Acquire

func (s Semaphore) Acquire(n int)

Acquire n resources.

s <- e

func (Semaphore) Release

func (s Semaphore) Release(n int)

Release n resources.

e := <-s

Jump to

Keyboard shortcuts

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