taskloop

package
v3.0.7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package taskloop implements a task loop to run tasks sequentially in a separate Goroutine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loop

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

Loop runs submitted task serially in a dedicated Goroutine

func New

func New(onClose func()) *Loop

New creates and starts a new task loop

func (*Loop) Close

func (l *Loop) Close() error

Close stops the loop after finishing the execution of the current task. Other pending tasks will not be executed.

func (*Loop) Deadline

func (l *Loop) Deadline() (deadline time.Time, ok bool)

Deadline returns the no valid time as task loops have no deadline.

func (*Loop) Done

func (l *Loop) Done() <-chan struct{}

Done returns a channel that's closed when the task loop has been stopped.

func (*Loop) Err

func (l *Loop) Err() error

Err returns nil if the task loop is still running. Otherwise it return errClosed if the loop has been closed/stopped.

func (*Loop) Run

func (l *Loop) Run(ctx context.Context, t func(context.Context)) error

Run serially executes the submitted callback. Blocking tasks must be cancelable by context.

func (*Loop) Value

func (l *Loop) Value(interface{}) interface{}

Value is not supported for task loops

Jump to

Keyboard shortcuts

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