queue

package
v0.0.0-...-23e6066 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package queue provides the implementation of buffer queue and interface of queue entry with Length method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	ilist.Linker
	Length() int64
	Release()
	Peek() Entry
}

Entry implements Linker interface and has both Length and Release methods.

type Queue

type Queue struct {
	ReaderQueue *waiter.Queue
	WriterQueue *waiter.Queue
	// contains filtered or unexported fields
}

Queue is a buffer queue.

func New

func New(ReaderQueue *waiter.Queue, WriterQueue *waiter.Queue, limit int64) *Queue

New allocates and initializes a new queue.

func (*Queue) Close

func (q *Queue) Close()

Close closes q for reading and writing. It is immediately not writable and will become unreadble will no more data is pending.

Both the read and write queues must be notified after closing: q.ReaderQueue.Notify(waiter.EventIn) q.WriterQueue.Notify(waiter.EventOut)

func (*Queue) Dequeue

func (q *Queue) Dequeue() (e Entry, notify bool, err *tcpip.Error)

Dequeue removes the first entry in the data queue, if one exists.

If notify is true, WriterQueue.Notify must be called: q.WriterQueue.Notify(waiter.EventOut)

func (*Queue) Enqueue

func (q *Queue) Enqueue(e Entry) (notify bool, err *tcpip.Error)

Enqueue adds an entry to the data queue if room is available.

If notify is true, ReaderQueue.Notify must be called: q.ReaderQueue.Notify(waiter.EventIn)

func (*Queue) IsReadable

func (q *Queue) IsReadable() bool

IsReadable determines if q is currently readable.

func (*Queue) IsWritable

func (q *Queue) IsWritable() bool

IsWritable determines if q is currently writable.

func (*Queue) MaxQueueSize

func (q *Queue) MaxQueueSize() int64

MaxQueueSize returns the maximum number of bytes storable in the queue.

func (*Queue) Peek

func (q *Queue) Peek() (Entry, *tcpip.Error)

Peek returns the first entry in the data queue, if one exists.

func (*Queue) QueuedSize

func (q *Queue) QueuedSize() int64

QueuedSize returns the number of bytes currently in the queue, that is, the number of readable bytes.

func (*Queue) Reset

func (q *Queue) Reset()

Reset empties the queue and Releases all of the Entries.

Both the read and write queues must be notified after resetting: q.ReaderQueue.Notify(waiter.EventIn) q.WriterQueue.Notify(waiter.EventOut)

Jump to

Keyboard shortcuts

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