queue

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

Queue implements lock-free FIFO freelist based queue. ref: https://dl.acm.org/citation.cfm?doid=248052.248106

Example
q := New()

q.Enqueue("1st item")
q.Enqueue("2nd item")
q.Enqueue("3rd item")

fmt.Println(q.Dequeue())
fmt.Println(q.Dequeue())
fmt.Println(q.Dequeue())
Output:

1st item
2nd item
3rd item

func New

func New() *Queue

New creates a new lock-free queue.

func (*Queue) Dequeue

func (q *Queue) Dequeue() interface{}

Dequeue removes and returns the value at the head of the queue. It returns nil if the queue is empty.

func (*Queue) Enqueue

func (q *Queue) Enqueue(v interface{})

Enqueue puts the given value v at the tail of the queue.

func (*Queue) Length

func (q *Queue) Length() uint64

Length returns the length of the queue.

Jump to

Keyboard shortcuts

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