lfqueue

package
v0.0.0-...-3670367 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockfreeQueue

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

LockfreeQueue is a goroutine-safe Queue implementation. The overall performance of LockfreeQueue is much better than List+Mutex(standard package).

func NewLockfreeQueue

func NewLockfreeQueue() *LockfreeQueue

NewLockfreeQueue is the only way to get a new, ready-to-use LockfreeQueue.

Example:

lfq := queue.NewLockfreeQueue()
lfq.Push(100)
v := lfq.Pop()

func (*LockfreeQueue) Pop

func (lfq *LockfreeQueue) Pop() interface{}

Pop returns (and removes) an element from the front of the queue, or nil if the queue is empty. It performs about 100% better than list.List.Front() and list.List.Remove() with sync.Mutex.

func (*LockfreeQueue) Push

func (lfq *LockfreeQueue) Push(val interface{})

Push inserts an element to the back of the queue. It performs exactly the same as list.List.PushBack() with sync.Mutex.

Jump to

Keyboard shortcuts

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