tasks

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const COMMAND_START_THRESHOLD = time.Millisecond * 10

we use this to check if the system is under stress right now. Hopefully this makes sense on other machines

View Source
const THROTTLE_TIME = time.Millisecond * 30

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncHandler added in v0.30.1

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

the purpose of an AsyncHandler is to ensure that if we have multiple long-running requests, we only handle the result of the latest one. For example, if I am searching for 'abc' and I have to type 'a' then 'b' then 'c' and each keypress dispatches a request to search for things with the string so-far, we'll be searching for 'a', 'ab', and 'abc', and it may be that 'abc' comes back first, then 'ab', then 'a' and we don't want to display the result for 'a' just because it came back last. AsyncHandler keeps track of the order in which things were dispatched so that we can ignore anything that comes back late.

func NewAsyncHandler added in v0.30.1

func NewAsyncHandler(onWorker func(func(gocui.Task))) *AsyncHandler

func (*AsyncHandler) Do added in v0.30.1

func (self *AsyncHandler) Do(f func() func())

type LinesToRead added in v0.38.0

type LinesToRead struct {
	// Total number of lines to read
	Total int

	// Number of lines after which we have read enough to fill the view, and can
	// do an initial refresh. Only set for the initial read request; -1 for
	// subsequent requests.
	InitialRefreshAfter int
}

type TaskOpts added in v0.39.0

type TaskOpts struct {
	// Channel that tells the task to stop, because another task wants to run.
	Stop chan struct{}

	// Only for tasks which are long-running, where we read more lines sporadically.
	// We use this to keep track of when a user's action is complete (i.e. all views
	// have been refreshed to display the results of their action)
	InitialContentLoaded func()
}

type ViewBufferManager

type ViewBufferManager struct {
	Log *logrus.Entry
	// contains filtered or unexported fields
}

func NewViewBufferManager

func NewViewBufferManager(
	log *logrus.Entry,
	writer io.Writer,
	beforeStart func(),
	refreshView func(),
	onEndOfInput func(),
	onNewKey func(),
	newGocuiTask func() gocui.Task,
) *ViewBufferManager

func (*ViewBufferManager) Close

func (self *ViewBufferManager) Close()

Close closes the task manager, killing whatever task may currently be running

func (*ViewBufferManager) GetTaskKey added in v0.30.1

func (m *ViewBufferManager) GetTaskKey() string

func (*ViewBufferManager) NewCmdTask

func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), prefix string, linesToRead LinesToRead, onDoneFn func()) func(TaskOpts) error

func (*ViewBufferManager) NewTask

func (self *ViewBufferManager) NewTask(f func(TaskOpts) error, key string) error

func (*ViewBufferManager) ReadLines

func (self *ViewBufferManager) ReadLines(n int)

Jump to

Keyboard shortcuts

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