task

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TaskExecutorClosedError = errors.New("任务执行器已关闭")

Functions

This section is empty.

Types

type Task

type Task interface {
	Do(interrupter chan struct{}) (interrupted bool)
}

func Func

func Func(fn func()) Task

func Interrupted

func Interrupted(fn func(interrupter chan struct{}) (interrupted bool)) Task

func Nop

func Nop() Task

type TaskExecutor

type TaskExecutor struct {
	lifecycle.Lifecycle
	// contains filtered or unexported fields
}

func NewTaskExecutor

func NewTaskExecutor(maxTask int) *TaskExecutor

func (*TaskExecutor) Async

func (e *TaskExecutor) Async(task Task) error

func (*TaskExecutor) RunFunc

func (*TaskExecutor) StartFunc

func (*TaskExecutor) Sync

func (e *TaskExecutor) Sync(task Task) error

func (*TaskExecutor) Try

func (e *TaskExecutor) Try(task Task) (ok bool, err error)

func (*TaskExecutor) Wait

func (e *TaskExecutor) Wait() error

Jump to

Keyboard shortcuts

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