queue

package
v0.0.0-...-5a547ea Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 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 Pool

type Pool struct {
	Cap int

	Chan chan interface{}
	// contains filtered or unexported fields
}

Pool the Queue instance.

func (Pool) Capacity

func (p Pool) Capacity() int

Capacity returns integer, capacity of queue.

func (*Pool) Exchange

func (p *Pool) Exchange(size uint) bool

Exchange returns boolean, if exchanges queue capacity with size successfully. returns fail if length of queue large than size.

func (*Pool) Free

func (p *Pool) Free()

Free release all queue items.

func (Pool) IsIdle

func (p Pool) IsIdle() bool

IsIdle returns true if queue is empty

func (*Pool) Pull

func (p *Pool) Pull() interface{}

Pull returns the first item of queue

func (*Pool) PullSync

func (p *Pool) PullSync() interface{}

PullSync returns the first item of queue, nil if queue is empty.

func (*Pool) Push

func (p *Pool) Push(i interface{}) int

Push returns integer, length of queue. Push a item to the queue.

func (*Pool) PushSlice

func (p *Pool) PushSlice(s []interface{}) int

PushSlice returns integer, length of queue. Push slice of items to the queue.

func (Pool) Size

func (p Pool) Size() int

Size returns integer, length of queue.

type Queue

type Queue interface {
	Capacity() int
	Size() int
	Push(i interface{}) int
	PushSlice(s []interface{}) int
	IsIdle() bool
	Pull() interface{}
	PullSync() interface{}
	Exchange(size uint) bool
	Free()
}

Queue defines a basic queue model.

func New

func New(size uint) Queue

New returns a Queue interface.

Jump to

Keyboard shortcuts

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