async

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 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 "github.com/Jaeel/fyne"`,
	},
	"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

func (ch *UnboundedCanvasObjectChan) Close()

Close closes the channel.

func (*UnboundedCanvasObjectChan) In

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

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

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

UnboundedInterfaceChan is a channel with an unbounded buffer for caching Interface objects.

func NewUnboundedInterfaceChan

func NewUnboundedInterfaceChan() *UnboundedInterfaceChan

NewUnboundedInterfaceChan returns a unbounded channel with unlimited capacity.

func (*UnboundedInterfaceChan) Close

func (ch *UnboundedInterfaceChan) Close()

Close closes the channel.

func (*UnboundedInterfaceChan) In

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

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

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

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