channel

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel interface {
	Push(n interface{}) bool  // push value into channel.
	Pop() (interface{}, bool) // pop value from channel.
	Close()                   // close channel immediately without waiting.
	CloseAndWait()            // close the channel and wait all element inside channle to be consumed by consumers.
	Count() int64             // return the current number of elements inside channel.
}

Channel describes a channel

type RecoverableChannel

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

RecoverableChannel recoverable channel

func NewRevocerableChannel

func NewRevocerableChannel(size int) *RecoverableChannel

NewRevocerableChannel new a recoverable channel

func (*RecoverableChannel) Close

func (rc *RecoverableChannel) Close()

Close close channel

func (*RecoverableChannel) CloseAndWait

func (rc *RecoverableChannel) CloseAndWait()

CloseAndWait close the channel, and wait until all data in the channel have been poped.

func (*RecoverableChannel) Count

func (rc *RecoverableChannel) Count() int64

Count returns current number of elements inside channel.

func (*RecoverableChannel) Pop

func (rc *RecoverableChannel) Pop() (interface{}, bool)

Pop pop value from channel

func (*RecoverableChannel) Push

func (rc *RecoverableChannel) Push(n interface{}) (ok bool)

Push push value into channel

return false if the channel has been closed

type SafeChannel

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

SafeChannel a safe channel that could prevent sending on closed channel

func NewSafeChannel

func NewSafeChannel(size int) *SafeChannel

NewSafeChannel new a channel

func (*SafeChannel) Close

func (sc *SafeChannel) Close()

Close close channel

func (*SafeChannel) CloseAndWait

func (sc *SafeChannel) CloseAndWait()

CloseAndWait close the channel, and wait until all data in the channel have been poped.

func (*SafeChannel) Count

func (sc *SafeChannel) Count() int64

Count returns current number of elements inside channel.

func (*SafeChannel) Pop

func (sc *SafeChannel) Pop() (interface{}, bool)

Pop pop value from channel

func (*SafeChannel) Push

func (sc *SafeChannel) Push(n interface{}) bool

Push push value into channel

return false if the channel has been closed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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