intq

package
v0.0.0-...-2081a44 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ring

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

Ring is a thread-safe bounded queue that stores int32 messages.

func NewRing

func NewRing(size uint64) *Ring

NewRing will allocate, initialize, and return a ring buffer with the specified size.

func (*Ring) Cap

func (rb *Ring) Cap() uint64

Cap returns the capacity of this ring buffer.

func (*Ring) Dispose

func (rb *Ring) Dispose()

Dispose will dispose of this queue and free any blocked threads in the Put and/or Get methods. Calling those methods on a disposed queue will return an error.

func (*Ring) Get

func (rb *Ring) Get() (int32, error)

Get will return the next item in the queue. This call will block if the queue is empty. This call will unblock when an item is added to the queue or Dispose is called on the queue. An error will be returned if the queue is disposed.

func (*Ring) IsDisposed

func (rb *Ring) IsDisposed() bool

IsDisposed will return a bool indicating if this queue has been disposed.

func (*Ring) Len

func (rb *Ring) Len() uint64

Len returns the number of items in the queue.

func (*Ring) Offer

func (rb *Ring) Offer(item int32) (bool, error)

Offer adds the provided item to the queue if there is space. If the queue is full, this call will return false. An error will be returned if the queue is disposed.

func (*Ring) Poll

func (rb *Ring) Poll(timeout time.Duration) (int32, error)

Poll will return the next item in the queue. This call will block if the queue is empty. This call will unblock when an item is added to the queue, Dispose is called on the queue, or the timeout is reached. An error will be returned if the queue is disposed or a timeout occurs. A non-positive timeout will block indefinitely.

func (*Ring) PollDeadline

func (rb *Ring) PollDeadline(deadline time.Time) (int32, error)

func (*Ring) Put

func (rb *Ring) Put(item int32) error

Put adds the provided item to the queue. If the queue is full, this call will block until an item is added to the queue or Dispose is called on the queue. An error will be returned if the queue is disposed.

Jump to

Keyboard shortcuts

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