Documentation
¶
Index ¶
- Constants
- Variables
- type Executor
- type RunFunc
- type Runnable
- type Runner
- type TimeoutScheduler
- func (s *TimeoutScheduler) Cancel(id int) bool
- func (s *TimeoutScheduler) Init(parentCtx context.Context)
- func (s *TimeoutScheduler) RunAfter(interval int, r Runner) int
- func (s *TimeoutScheduler) RunAt(ts int64, r Runner) int
- func (s *TimeoutScheduler) RunEvery(interval int, r Runner) int
- func (s *TimeoutScheduler) Shutdown()
- func (s *TimeoutScheduler) Start()
- func (s *TimeoutScheduler) StopAndWait()
- type TimerHeap
Constants ¶
View Source
const ( TimerPrecision = 50 // 精度为50ms TimerChanCapacity = 1000 // TimerCapacity = 64 )
Variables ¶
View Source
var ( ErrExecutorClosed = errors.New("executor is closed already") ErrExecutorBusy = errors.New("executor queue is full") )
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
执行器
func NewExecutor ¶
func (*Executor) StopAndWait ¶
func (e *Executor) StopAndWait()
type TimeoutScheduler ¶
type TimeoutScheduler struct { C chan *timerNode // 到期的定时器 // contains filtered or unexported fields }
最小堆定时器
func NewTimeoutScheduler ¶
func NewTimeoutScheduler(parentCtx context.Context) *TimeoutScheduler
func (*TimeoutScheduler) Cancel ¶
func (s *TimeoutScheduler) Cancel(id int) bool
func (*TimeoutScheduler) Init ¶
func (s *TimeoutScheduler) Init(parentCtx context.Context)
func (*TimeoutScheduler) RunAfter ¶
func (s *TimeoutScheduler) RunAfter(interval int, r Runner) int
创建一个定时器,在`interval`毫秒后运行`r`
func (*TimeoutScheduler) RunAt ¶
func (s *TimeoutScheduler) RunAt(ts int64, r Runner) int
创建一个定时器,在`ts`毫秒时间戳运行`r`
func (*TimeoutScheduler) RunEvery ¶
func (s *TimeoutScheduler) RunEvery(interval int, r Runner) int
创建一个定时器,每隔`interval`毫秒运行一次`r`
func (*TimeoutScheduler) Shutdown ¶
func (s *TimeoutScheduler) Shutdown()
func (*TimeoutScheduler) Start ¶
func (s *TimeoutScheduler) Start()
func (*TimeoutScheduler) StopAndWait ¶
func (s *TimeoutScheduler) StopAndWait()
Click to show internal directories.
Click to hide internal directories.