schedule

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DelayHandler

type DelayHandler interface {
	OnTimer()
}

DelayHandler 调度程序 需要传递参数通过 struct 传递

type Schedule

type Schedule struct {
	IDGen uint64
	// contains filtered or unexported fields
}

Schedule 时间表 命名也只是不想与标准库Timer重名而已 定时时间精确到秒,不精确管理goroutine的退出 主要逻辑只不过是对标准库Timer、Ticker封装管理而已

func New

func New() *Schedule

func (*Schedule) Add

func (s *Schedule) Add(delayHandler DelayHandler, duration time.Duration, persistence bool) (TID uint64)

Add 添加

func (*Schedule) Remove

func (s *Schedule) Remove(id uint64)

Remove 移除

func (*Schedule) Run

func (s *Schedule) Run(ctx context.Context)

func (*Schedule) Start

func (s *Schedule) Start(ctx context.Context)

Start 开始

func (*Schedule) Surplus

func (s *Schedule) Surplus(id uint64) (duration time.Duration)

Surplus 剩余

Jump to

Keyboard shortcuts

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