eventqueue

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package eventqueue provides an unboud FIFO queue of events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Throttled

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

Throttled is an unbound and throttled FIFO queue of terminal events. Throttled must not be copied, pass it by reference only. This implementation is thread-safe.

func NewThrottled

func NewThrottled(maxRep int) *Throttled

NewThrottled returns a new Throttled queue of terminal events.

This queue scans the queue content on each Push call and won't Push the event if there already is a continuous chain of exactly the same events en queued. The argument maxRep specifies the maximum number of repetitive events.

Call Close() when done with the queue.

func (*Throttled) Close

func (t *Throttled) Close()

Close should be called when the queue isn't needed anymore.

func (*Throttled) Empty

func (t *Throttled) Empty() bool

Empty determines if the queue is empty.

func (*Throttled) Pop

func (t *Throttled) Pop() terminalapi.Event

Pop pops an event from the queue. Returns nil if the queue is empty.

func (*Throttled) Pull

func (t *Throttled) Pull(ctx context.Context) terminalapi.Event

Pull is like Pop(), but blocks until an item is available or the context expires. Returns a nil event if the context expired.

func (*Throttled) Push

func (t *Throttled) Push(e terminalapi.Event)

Push pushes an event onto the queue.

type Unbound

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

Unbound is an unbound FIFO queue of terminal events. Unbound must not be copied, pass it by reference only. This implementation is thread-safe.

func New

func New() *Unbound

New returns a new Unbound queue of terminal events. Call Close() when done with the queue.

func (*Unbound) Close

func (u *Unbound) Close()

Close should be called when the queue isn't needed anymore.

func (*Unbound) Empty

func (u *Unbound) Empty() bool

Empty determines if the queue is empty.

func (*Unbound) Pop

func (u *Unbound) Pop() terminalapi.Event

Pop pops an event from the queue. Returns nil if the queue is empty.

func (*Unbound) Pull

func (u *Unbound) Pull(ctx context.Context) terminalapi.Event

Pull is like Pop(), but blocks until an item is available or the context expires. Returns a nil event if the context expired.

func (*Unbound) Push

func (u *Unbound) Push(e terminalapi.Event)

Push pushes an event onto the queue.

Jump to

Keyboard shortcuts

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