task

package
v1.63.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Demo

func Demo()

Types

type PriorityQueue

type PriorityQueue []*Task

PriorityQueue 实现了 heap.Interface 接口

func (PriorityQueue) Len

func (my PriorityQueue) Len() int

func (PriorityQueue) Less

func (my PriorityQueue) Less(i, j int) bool

Less 决定了优先级的排序规则 这里我们定义 Priority 越大,优先级越高

func (*PriorityQueue) Pop

func (my *PriorityQueue) Pop() any

func (*PriorityQueue) Push

func (my *PriorityQueue) Push(x any)

func (PriorityQueue) Swap

func (my PriorityQueue) Swap(i, j int)

type Task

type Task struct {
	ID       string
	Priority int          // 数值越大,优先级越高
	Index    int          // 用于 heap 内部维护
	Fn       func() error // 用于执行
	Error    error        // 执行结果
}

type TaskPool

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

func GetTaskPoolOnce added in v1.62.2

func GetTaskPoolOnce(tasks ...*Task) *TaskPool

GetTaskPoolOnce 获取单例

func (*TaskPool) GO

func (my *TaskPool) GO() []*Task

GO 执行任务

func (*TaskPool) PushTask

func (my *TaskPool) PushTask(tasks ...*Task) *TaskPool

PushTask 推送任务

Jump to

Keyboard shortcuts

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