timerengine

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RingSize define the ring buffer size for timer engine
	RingSize = 3600
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task interface {
	Run()
}

Task define the Task interface runned by timer engine

type TaskFunc

type TaskFunc func()

TaskFunc define the task func type

func (TaskFunc) Run

func (f TaskFunc) Run()

Run adapt the TaskFunc to taskengine.Task interface

type TimerEngine

type TimerEngine struct {
	// contains filtered or unexported fields
}

TimerEngine define the timer engine nolint:maligned

func New

func New(name string, concurrencyLevel int, logger *zap.Logger) *TimerEngine

New create a new TimerEngine

func (*TimerEngine) Name

func (te *TimerEngine) Name() string

Name return the name of timer engine

func (*TimerEngine) Schedule

func (te *TimerEngine) Schedule(task Task, delay int64) (timerTask *TimerTask)

Schedule schedule a timer task with delay

func (*TimerEngine) Start

func (te *TimerEngine) Start()

Start start the timer engine

func (*TimerEngine) Stop

func (te *TimerEngine) Stop()

Stop stop the timer engine

type TimerTask

type TimerTask struct {
	sync.Mutex
	ID uint64
	// contains filtered or unexported fields
}

TimerTask define the timer task

func (*TimerTask) Cancel

func (timerTask *TimerTask) Cancel() (ok bool)

Cancel cancel the task

Jump to

Keyboard shortcuts

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