async

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 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

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

func NewCanvasObjectQueue() *CanvasObjectQueue

NewCanvasObjectQueue returns a queue for caching values.

func (*CanvasObjectQueue) In

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

func (*CanvasObjectQueue) Len

func (q *CanvasObjectQueue) Len() uint64

Len returns the length of the queue.

func (*CanvasObjectQueue) Out

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

type Position

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

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

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

func (*Position) Store

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

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

type Size

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

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

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

func (*Size) Store

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

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

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

NewUnboundedChan returns a unbounded channel with unlimited capacity.

func (*UnboundedChan[T]) Close

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

Close closes the channel.

func (*UnboundedChan[T]) In

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

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

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

func NewUnboundedInterfaceChan() *UnboundedInterfaceChan

NewUnboundedInterfaceChan returns a unbounded channel, of any type, with unlimited capacity.

type UnboundedStructChan

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

func NewUnboundedStructChan() *UnboundedStructChan

NewUnboundedStructChan returns a unbounded channel with unlimited capacity.

func (*UnboundedStructChan) Close

func (ch *UnboundedStructChan) Close()

Close closes the channel.

func (*UnboundedStructChan) In

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

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