tasks

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tasks is a port of the pattern behind lazydocker's TaskManager: one task is one goroutine plus a cancelable context, and starting a new task stops the previous one.

It only ever owns rendering/reading goroutines. Cancelling a task must never stop the underlying shell process, which keeps running in the background even when its session is not displayed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager runs at most one task at a time: starting a new one stops whichever was running first. It only ever owns display/reading goroutines — never anything that should keep running once nobody is watching it (that is what pkg/session's own drain goroutines are for; cancelling a task here must never reach into a session's process).

func NewManager

func NewManager() *Manager

NewManager returns an empty Manager, ready to run tasks.

func (*Manager) NewTask

func (m *Manager) NewTask(f func(ctx context.Context))

NewTask stops the currently running task, if any, then starts f in its own goroutine with a fresh cancelable context.

func (*Manager) NewTickerTask

func (m *Manager) NewTickerTask(interval time.Duration, f func(ctx context.Context))

NewTickerTask is NewTask wrapping f in a loop that also runs on every tick of interval, until stopped. f runs once immediately, then again on each tick — the same "run once, then on ticks" shape as gui.goEvery.

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the currently running task, if any.

Jump to

Keyboard shortcuts

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