queue

package module
v0.0.0-...-2a29819 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: BSD-3-Clause Imports: 2 Imported by: 0

README

queue

import "github.com/n1060/queue"

Package queue provides a lock-free queue. The underlying algorithm is one proposed by Michael and Scott. https://doi.org/10.1145/248052.248106

Usage

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

Queue is a lock-free unbounded queue.

func NewQueue
func NewQueue() (q *Queue)

NewQueue returns a pointer to an empty queue.

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

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

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

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

Documentation

Overview

Package queue provides a lock-free queue. The underlying algorithm is one proposed by Michael and Scott. https://doi.org/10.1145/248052.248106

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 is a lock-free unbounded queue.

Example
q := NewQueue()

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

fmt.Println(q.Deq())
fmt.Println(q.Deq())
fmt.Println(q.Deq())
Output:
1st item
2nd item
3rd item

func NewQueue

func NewQueue() (q *Queue)

NewQueue returns a pointer to an empty queue.

func (*Queue) Deq

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

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

func (*Queue) Enq

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

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

Jump to

Keyboard shortcuts

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