task

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTask

func AddTask(task func())

AddTask 添加任务

func NewPool

func NewPool(opts ...Option) *defaultPool

func Release

func Release()

Release 释放任务

func SetContextProvider added in v1.0.9

func SetContextProvider(provider ContextProvider)

SetContextProvider 设置 Context 提供者(由 dawn 包调用)

func SetPool

func SetPool(pool Pool)

SetPool 设置任务池

Types

type ContextProvider added in v1.0.9

type ContextProvider interface {
	// TaskPool 获取任务池
	TaskPool() Pool
}

ContextProvider Context 提供者接口,用于避免循环依赖

func GetContextProvider added in v1.0.9

func GetContextProvider() ContextProvider

GetContextProvider 获取 Context 提供者

type Option

type Option func(o *options)

func WithDisablePurge

func WithDisablePurge(disablePurge bool) Option

WithDisablePurge 设置是否禁用清除

func WithNonblocking

func WithNonblocking(nonblocking bool) Option

WithNonblocking 设置是否非阻塞

func WithSize

func WithSize(size int) Option

WithSize 设置任务池大小

type Pool

type Pool interface {
	// AddTask 添加任务
	AddTask(task func()) error
	// Release 释放任务
	Release()
}

func GetPool

func GetPool() Pool

GetPool 获取任务池 优先从 Context 获取,如果没有关联 Context 则使用全局变量

Jump to

Keyboard shortcuts

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