timer

package
v1.17.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Now

func Now() time.Time

func ReleaseTimer

func ReleaseTimer(timer *Timer)

func StartTimer

func StartTimer(minTimerInterval time.Duration, maxTimerNum int)

Types

type Cron

type Cron struct {
	Timer
}

Cron

func (*Cron) Do

func (c *Cron) Do()

func (*Cron) IsRef

func (c *Cron) IsRef() bool

func (*Cron) Ref

func (c *Cron) Ref()

func (*Cron) Reset

func (c *Cron) Reset()

func (*Cron) UnRef

func (c *Cron) UnRef()

type CronExpr

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

Field name | Mandatory? | Allowed values | Allowed special characters ---------- | ---------- | -------------- | -------------------------- Seconds | No | 0-59 | * / , - Minutes | Yes | 0-59 | * / , - Hours | Yes | 0-23 | * / , - Day of month | Yes | 1-31 | * / , - Month | Yes | 1-12 | * / , - Day of week | Yes | 0-6 | * / , -

func NewCronExpr

func NewCronExpr(expr string) (cronExpr *CronExpr, err error)

goroutine safe

func (*CronExpr) Next

func (e *CronExpr) Next(t time.Time) time.Time

goroutine safe

type Dispatcher

type Dispatcher struct {
	ChanTimer chan ITimer
}

one dispatcher per goroutine (goroutine not safe)

func NewDispatcher

func NewDispatcher(l int) *Dispatcher

func (*Dispatcher) AfterFunc

func (dispatcher *Dispatcher) AfterFunc(d time.Duration, cb func(uint64, interface{}), cbEx func(*Timer), onTimerClose OnCloseTimer, onAddTimer OnAddTimer) *Timer

func (*Dispatcher) CronFunc

func (dispatcher *Dispatcher) CronFunc(cronExpr *CronExpr, cb func(uint64, interface{}), cbEx func(*Cron), onTimerClose OnCloseTimer, onAddTimer OnAddTimer) *Cron

func (*Dispatcher) TickerFunc

func (dispatcher *Dispatcher) TickerFunc(d time.Duration, cb func(uint64, interface{}), cbEx func(*Ticker), onTimerClose OnCloseTimer, onAddTimer OnAddTimer) *Ticker

type ITimer

type ITimer interface {
	GetId() uint64
	Cancel()
	GetName() string
	IsActive() bool
	IsOpen() bool
	Open(bOpen bool)
	AppendChannel(timer ITimer)
	Do()
	GetFireTime() time.Time
	SetupTimer(now time.Time) error
}

ITimer

func SetupTimer

func SetupTimer(timer ITimer) ITimer

type OnAddTimer

type OnAddTimer func(timer ITimer)

type OnCloseTimer

type OnCloseTimer func(timer ITimer)

type Ticker

type Ticker struct {
	Timer
}

Ticker

func (*Ticker) Do

func (c *Ticker) Do()

func (*Ticker) IsRef

func (c *Ticker) IsRef() bool

func (*Ticker) Ref

func (c *Ticker) Ref()

func (*Ticker) Reset

func (c *Ticker) Reset()

func (*Ticker) UnRef

func (c *Ticker) UnRef()

type Timer

type Timer struct {
	Id uint64

	C chan ITimer //定时器管道

	AdditionData interface{} //定时器附加数据
	// contains filtered or unexported fields
}

Timer

func NewTimer

func NewTimer(d time.Duration) *Timer

func (*Timer) AppendChannel

func (t *Timer) AppendChannel(timer ITimer)

func (*Timer) Cancel

func (t *Timer) Cancel()

func (*Timer) Do

func (t *Timer) Do()

func (*Timer) GetFireTime

func (t *Timer) GetFireTime() time.Time

func (*Timer) GetId

func (t *Timer) GetId() uint64

func (*Timer) GetInterval

func (t *Timer) GetInterval() time.Duration

func (*Timer) GetName

func (t *Timer) GetName() string

func (*Timer) IsActive

func (t *Timer) IsActive() bool

判断定时器是否已经取消

func (*Timer) IsOpen

func (t *Timer) IsOpen() bool

func (*Timer) IsRef

func (t *Timer) IsRef() bool

func (*Timer) Open

func (t *Timer) Open(bOpen bool)

func (*Timer) Ref

func (t *Timer) Ref()

func (*Timer) Reset

func (t *Timer) Reset()

func (*Timer) SetupTimer

func (t *Timer) SetupTimer(now time.Time) error

func (*Timer) UnRef

func (t *Timer) UnRef()

Jump to

Keyboard shortcuts

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