async

package
v2.1.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package async provides unbounded channel data 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.

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.

One must close such a channel via Close() method, closing the input channel via close() built-in method can leads to memory leak.

To support a new type, one may add the required data in the gen.go, for instances:

types := map[string]data{
	"fyne_canvasobject.go": data{
		Type: "fyne.CanvasObject",
		Name: "CanvasObject",
		Imports: `import "fyne.io/fyne/v2"`,
	},
	"func.go": data{
		Type:    "func()",
		Name:    "Func",
		Imports: "",
	},
}

then run: `go generate ./...` to generate more desired unbounded channels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UnboundedCanvasObjectChan

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

UnboundedCanvasObjectChan is a channel with an unbounded buffer for caching CanvasObject objects.

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.

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.

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.

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. Especially, rendering and even processing tasks.

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