gqueue

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package gqueue provides a dynamic/static concurrent-safe queue.

Features:

1. FIFO queue(data -> list -> chan);

2. Fast creation and initialization;

3. Support dynamic queue size(unlimited queue size);

4. Blocking when reading data from queue;

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue struct {
	C chan interface{} // Underlying channel for data reading.
	// contains filtered or unexported fields
}

func New

func New(limit ...int) *Queue

New returns a queue object. Param <limit> is optional and it is not limited by default.

func (*Queue) Close

func (q *Queue) Close()

Close closes the queue. Notice: It would notify all goroutines exit immediately, which are blocked reading by Pop method).

func (*Queue) Pop

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

Pop pops an item from the queue in FIFO way. Note that it would return nil immediately if the Pop method is called after the queue is closed.

func (*Queue) Push

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

Push pushes the data <v> into the queue. Note that it would panics if the Push method is called after the queue is closed.

func (*Queue) Size

func (q *Queue) Size() int

Size returns the length of the queue.

Jump to

Keyboard shortcuts

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