conc

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: GPL-3.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCanceled is returned from functions that were canceled prematurely.
	ErrCanceled = errors.New("Canceled")
)

Functions

func DaemonFunc added in v0.1.2

func DaemonFunc(f func(Context)) func()

DaemonFunc runs the specified function as daemon. Calling the returned function signals that the daemon function should be canceled and waits until the daemon function returns.

Types

type Context

type Context interface {
	// Done returns a channel that is closed when work should be canceled.
	Done() <-chan struct{}

	// IsDone returns true, when work should be canceled.
	IsDone() bool

	// Sleep pauses the execution for the specified duration. If the context is
	// canceled, Sleep returns immediately ErrCanceled.
	Sleep(time.Duration) error
}

type DaemonPool added in v0.1.4

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

DaemonPool runs any number of functions as daemon. All functions can be canceled simultaneously with Close.

func (*DaemonPool) Close added in v0.1.4

func (d *DaemonPool) Close()

Close signals to all running daemon functions that they should be canceled and waits until all daemon functions return.

func (*DaemonPool) Run added in v0.1.4

func (d *DaemonPool) Run(f func(Context))

Run runs the specified function as daemon. The specified function can spawn additional daemon functions.

type DebouncedFunc added in v0.1.7

type DebouncedFunc struct {
	Dur  time.Duration
	Func func()
	// contains filtered or unexported fields
}

DebouncedFunc waits the specified amount of time after a trigger call and then calls the specified function. Further trigger calls while waiting are discarded and restart the time span. A DebouncedFunc must not be copied after first use.

func (*DebouncedFunc) Cancel added in v0.1.7

func (d *DebouncedFunc) Cancel()

func (*DebouncedFunc) Trigger added in v0.1.7

func (d *DebouncedFunc) Trigger()

Jump to

Keyboard shortcuts

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