background

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClosedFromContext

func ClosedFromContext(ctx context.Context) (closed chan struct{}, ok bool)

func NewContextWithClosed

func NewContextWithClosed(ctx context.Context, closed chan struct{}) context.Context

Types

type Background

type Background struct {
	// contains filtered or unexported fields
}
var Default *Background = New(log.DefaultLogger)

func New

func New(logger log.Logger) *Background

func (*Background) Add

func (bg *Background) Add(f BackgroundFunc)

func (*Background) Close

func (bg *Background) Close(ctx context.Context) error

Close 等待所有后台任务退出并返回

func (*Background) Launch

func (bg *Background) Launch(ctx context.Context)

Launch 非阻塞的启动所有已添加的后台任务

func (*Background) SetLogger

func (bg *Background) SetLogger(logger log.Logger)

func (*Background) Start

func (bg *Background) Start(ctx context.Context) error

Start implements transport.Server.

func (*Background) Stop

func (bg *Background) Stop(ctx context.Context) error

Stop implements transport.Server.

type BackgroundFunc

type BackgroundFunc func(ctx context.Context)

非线程安全的后台任务管理器 多次调用 Launch/Close 行为是未定义的

Jump to

Keyboard shortcuts

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