Documentation
¶
Index ¶
- func ClosedFromContext(ctx context.Context) (closed chan struct{}, ok bool)
- func NewContextWithClosed(ctx context.Context, closed chan struct{}) context.Context
- type Background
- func (bg *Background) Add(f BackgroundFunc)
- func (bg *Background) Close(ctx context.Context) error
- func (bg *Background) Launch(ctx context.Context)
- func (bg *Background) SetLogger(logger log.Logger)
- func (bg *Background) Start(ctx context.Context) error
- func (bg *Background) Stop(ctx context.Context) error
- type BackgroundFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClosedFromContext ¶
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)
type BackgroundFunc ¶
非线程安全的后台任务管理器 多次调用 Launch/Close 行为是未定义的
Click to show internal directories.
Click to hide internal directories.