async

package
v2.5.3-rc4 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 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 Position added in v2.5.0

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

Position is an atomic version of fyne.Position. Loads and stores are guaranteed to happen using a single atomic operation.

func (*Position) Load added in v2.5.0

func (p *Position) Load() fyne.Position

Load performs an atomic load on the fyne.Position value.

func (*Position) Store added in v2.5.0

func (p *Position) Store(pos fyne.Position)

Store performs an atomic store on the fyne.Position value.

type Size added in v2.5.0

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

Size is an atomic version of fyne.Size. Loads and stores are guaranteed to happen using a single atomic operation.

func (*Size) Load added in v2.5.0

func (s *Size) Load() fyne.Size

Load performs an atomic load on the fyne.Size value.

func (*Size) Store added in v2.5.0

func (s *Size) Store(size fyne.Size)

Store performs an atomic store on the fyne.Size value.

type UnboundedCanvasObjectChan

type UnboundedCanvasObjectChan = UnboundedChan[fyne.CanvasObject]

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

type UnboundedChan added in v2.5.0

type UnboundedChan[T any] struct {
	// contains filtered or unexported fields
}

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

func NewUnboundedCanvasObjectChan

func NewUnboundedCanvasObjectChan() *UnboundedChan[fyne.CanvasObject]

NewUnboundedCanvasObjectChan returns a unbounded channel, of canvas objects, with unlimited capacity.

func NewUnboundedChan added in v2.5.0

func NewUnboundedChan[T any]() *UnboundedChan[T]

NewUnboundedChan returns a unbounded channel with unlimited capacity.

func (*UnboundedChan[T]) Close added in v2.5.0

func (ch *UnboundedChan[T]) Close()

Close closes the channel.

func (*UnboundedChan[T]) In added in v2.5.0

func (ch *UnboundedChan[T]) In() chan<- T

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

func (*UnboundedChan[T]) Out added in v2.5.0

func (ch *UnboundedChan[T]) Out() <-chan T

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

type UnboundedFuncChan

type UnboundedFuncChan = UnboundedChan[func()]

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, of func(), with unlimited capacity.

type UnboundedInterfaceChan added in v2.1.1

type UnboundedInterfaceChan = UnboundedChan[any]

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, of any type, with unlimited capacity.

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