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) 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 (*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