async

package
v2.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package async provides unbounded channel and queue structures that are designed for caching unlimited number of a concrete type. For better performance, a given type should be less or euqal than 16 bytes.

The difference of an unbounded channel or queue is that unbounde channels can utilize select and channel semantics, whereas queue cannot. A user of this package should balance this tradeoff. For instance, an unbounded channel can provide zero waiting cost when trying to receiving an object when the receiving select statement has a default case, and a queue can only receive the object with a time amount of time, but depending on the number of queue item producer, the receiving time may increase accordingly.

Delicate dance: One must aware that an unbounded channel may lead to OOM when the consuming speed of the buffer is lower than the producing speed constantly. However, such a channel may be fairly used for event delivering if the consumer of the channel consumes the incoming forever, such as even processing.

This package involves code generators, see gen.go for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CanvasObjectQueue added in v2.2.0

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

CanvasObjectQueue implements lock-free FIFO freelist based queue.

Reference: https://dl.acm.org/citation.cfm?doid=248052.248106

func NewCanvasObjectQueue added in v2.2.0

func NewCanvasObjectQueue() *CanvasObjectQueue

NewCanvasObjectQueue returns a queue for caching values.

func (*CanvasObjectQueue) In added in v2.2.0

func (q *CanvasObjectQueue) In(v fyne.CanvasObject)

In puts the given value at the tail of the queue.

func (*CanvasObjectQueue) Len added in v2.2.0

func (q *CanvasObjectQueue) Len() uint64

Len returns the length of the queue.

func (*CanvasObjectQueue) Out added in v2.2.0

func (q *CanvasObjectQueue) Out() fyne.CanvasObject

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

type UnboundedCanvasObjectChan

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

UnboundedCanvasObjectChan is a channel with an unbounded buffer for caching CanvasObject objects. A channel must be closed via Close method.

func NewUnboundedCanvasObjectChan

func NewUnboundedCanvasObjectChan() *UnboundedCanvasObjectChan

NewUnboundedCanvasObjectChan returns a unbounded channel with unlimited capacity.

func (*UnboundedCanvasObjectChan) Close added in v2.1.1

func (ch *UnboundedCanvasObjectChan) Close()

Close closes the channel.

func (*UnboundedCanvasObjectChan) In

func (ch *UnboundedCanvasObjectChan) In() chan<- fyne.CanvasObject

In returns the send channel of the given channel, which can be used to send values to the channel.

func (*UnboundedCanvasObjectChan) Out

func (ch *UnboundedCanvasObjectChan) Out() <-chan fyne.CanvasObject

Out returns the receive channel of the given channel, which can be used to receive values from the channel.

type UnboundedFuncChan

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

UnboundedFuncChan is a channel with an unbounded buffer for caching Func objects. A channel must be closed via Close method.

func NewUnboundedFuncChan

func NewUnboundedFuncChan() *UnboundedFuncChan

NewUnboundedFuncChan returns a unbounded channel with unlimited capacity.

func (*UnboundedFuncChan) Close added in v2.1.1

func (ch *UnboundedFuncChan) Close()

Close closes the channel.

func (*UnboundedFuncChan) In

func (ch *UnboundedFuncChan) In() chan<- func()

In returns the send channel of the given channel, which can be used to send values to the channel.

func (*UnboundedFuncChan) Out

func (ch *UnboundedFuncChan) Out() <-chan func()

Out returns the receive channel of the given channel, which can be used to receive values from the channel.

type UnboundedInterfaceChan added in v2.1.1

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

UnboundedInterfaceChan is a channel with an unbounded buffer for caching Interface objects. A channel must be closed via Close method.

func NewUnboundedInterfaceChan added in v2.1.1

func NewUnboundedInterfaceChan() *UnboundedInterfaceChan

NewUnboundedInterfaceChan returns a unbounded channel with unlimited capacity.

func (*UnboundedInterfaceChan) Close added in v2.1.1

func (ch *UnboundedInterfaceChan) Close()

Close closes the channel.

func (*UnboundedInterfaceChan) In added in v2.1.1

func (ch *UnboundedInterfaceChan) In() chan<- interface{}

In returns the send channel of the given channel, which can be used to send values to the channel.

func (*UnboundedInterfaceChan) Out added in v2.1.1

func (ch *UnboundedInterfaceChan) Out() <-chan interface{}

Out returns the receive channel of the given channel, which can be used to receive values from the channel.

type UnboundedStructChan added in v2.1.1

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

UnboundedStructChan is a channel with an unbounded buffer for caching struct{} objects. This implementation is a specialized version that optimizes for struct{} objects than other types. A channel must be closed via Close method.

func NewUnboundedStructChan added in v2.1.1

func NewUnboundedStructChan() *UnboundedStructChan

NewUnboundedStructChan returns a unbounded channel with unlimited capacity.

func (*UnboundedStructChan) Close added in v2.1.1

func (ch *UnboundedStructChan) Close()

Close closes the channel.

func (*UnboundedStructChan) In added in v2.1.1

func (ch *UnboundedStructChan) In() chan<- struct{}

In returns a send-only channel that can be used to send values to the channel.

func (*UnboundedStructChan) Out added in v2.1.1

func (ch *UnboundedStructChan) Out() <-chan struct{}

Out returns a receive-only channel that can be used to receive values from the channel.

Jump to

Keyboard shortcuts

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