queue

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoElement the queue has no element
	ErrNoElement = errors.New("the queue has no element")
	// ErrWaitTimeOut ..
	ErrWaitTimeOut = errors.New("wait time out")
	// ErrNotComparator the element not implement the Comparator
	ErrNotComparator = errors.New("the element not implement the Comparator")
)

Functions

This section is empty.

Types

type ArrayQueue

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

ArrayQueue ..

func (*ArrayQueue) Len

func (p *ArrayQueue) Len() int

Len is the number of elements in the collection.

func (*ArrayQueue) Less

func (p *ArrayQueue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*ArrayQueue) Pop

func (p *ArrayQueue) Pop() interface{}

Pop remove and return element Len() - 1.

func (*ArrayQueue) Push

func (p *ArrayQueue) Push(x interface{})

Push .. add x as element Len()

func (*ArrayQueue) Swap

func (p *ArrayQueue) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type BlockedLinkQueue

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

BlockedLinkQueue 链表阻塞队列

func NewBlockedLinkQueue

func NewBlockedLinkQueue() *BlockedLinkQueue

NewBlockedLinkQueue build the NewBlockedLinkQueue pointer

func (*BlockedLinkQueue) Len

func (b *BlockedLinkQueue) Len() int

Len return the length of the queue

func (*BlockedLinkQueue) Pop

func (b *BlockedLinkQueue) Pop(timeOut time.Duration) (interface{}, error)

Pop pop the element

func (*BlockedLinkQueue) Push

func (b *BlockedLinkQueue) Push(ctx context.Context, v interface{}) error

Push push the element

type BlockedQueue

type BlockedQueue interface {
	Push(ctx context.Context, v interface{}) error
	Pop(waitTime time.Duration) (interface{}, error)
	Len() int
}

BlockedQueue ..

type Comparator

type Comparator interface {
	Less(i interface{}) bool
}

Comparator like the java Comparator

type DefaultTaskQueue

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

DefaultTaskQueue the common implement for the task queue

func NewDefaultPriorityTaskQueue

func NewDefaultPriorityTaskQueue(taskNum int) *DefaultTaskQueue

NewDefaultPriorityTaskQueue ..

func NewDefaultTaskQueue

func NewDefaultTaskQueue(taskNum int) *DefaultTaskQueue

NewDefaultTaskQueue ..

func (*DefaultTaskQueue) Close

func (t *DefaultTaskQueue) Close()

Close ..

func (*DefaultTaskQueue) SetParallelTaskNum

func (t *DefaultTaskQueue) SetParallelTaskNum(taskNum int)

SetParallelTaskNum ..

func (*DefaultTaskQueue) Start

func (t *DefaultTaskQueue) Start()

Start ..

func (*DefaultTaskQueue) SubmitPriorityTask

func (t *DefaultTaskQueue) SubmitPriorityTask(task PriorityTask) bool

SubmitPriorityTask ..

func (*DefaultTaskQueue) SubmitTask

func (t *DefaultTaskQueue) SubmitTask(task Task) bool

SubmitTask ..

func (*DefaultTaskQueue) TaskSize

func (t *DefaultTaskQueue) TaskSize() int

TaskSize ..

func (*DefaultTaskQueue) Wait

func (t *DefaultTaskQueue) Wait(timeOut time.Duration) error

Wait ..

type PriorityBlockedQueue

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

PriorityBlockedQueue ..

func NewPriorityBlockedQueue

func NewPriorityBlockedQueue() *PriorityBlockedQueue

NewPriorityBlockedQueue ..

func (*PriorityBlockedQueue) Len

func (b *PriorityBlockedQueue) Len() int

Len return the length of the queue

func (*PriorityBlockedQueue) Pop

func (b *PriorityBlockedQueue) Pop(timeOut time.Duration) (interface{}, error)

Pop pop the element

func (*PriorityBlockedQueue) Push

func (b *PriorityBlockedQueue) Push(ctx context.Context, v interface{}) error

Push push the element

type PriorityTask

type PriorityTask interface {
	Comparator
	Run() error
}

PriorityTask ..

type Task

type Task interface {
	Run() error
}

Task you should implement

Jump to

Keyboard shortcuts

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