Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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()