timer

package
v0.0.0-...-bfb5c6f Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const (
	//默认安全时间调度器的容量
	TIMERLEN = 2048
	//默认最大误差值100毫秒
	ERRORMAX = 100
	//默认最大触发队列缓冲大小
	TRIGGERMAX = 2048
	//默认hashwheel分级
	LEVEL = 12
)

协程安全的timer

View Source
const (
	DEFAULT_LEVEL = 12
)

Variables

This section is empty.

Functions

func UnixTS

func UnixTS() int64

Types

type DelayCall

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

func (*DelayCall) Call

func (this *DelayCall) Call()

func (*DelayCall) String

func (this *DelayCall) String() string

type HashWheel

type HashWheel struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewHashWheel

func NewHashWheel(title string, level int, linterval int64, maxCap uint32) *HashWheel

func (*HashWheel) Add2WheelChain

func (this *HashWheel) Add2WheelChain(tid uint32, t *SafeTimer) error

func (*HashWheel) AddNext

func (this *HashWheel) AddNext(next *HashWheel)

func (*HashWheel) Count

func (this *HashWheel) Count() int

func (*HashWheel) GetTriggerWithIn

func (this *HashWheel) GetTriggerWithIn(ms int64) map[uint32]*SafeTimer

func (*HashWheel) RemoveFromWheelChain

func (this *HashWheel) RemoveFromWheelChain(tid uint32)

func (*HashWheel) RunWheel

func (this *HashWheel) RunWheel()

时间轮跑起来

type ParamNull

type ParamNull struct{}

type SafeTimer

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

func NewSafeTimer

func NewSafeTimer(delay int64, delayCall *DelayCall) *SafeTimer

type SafeTimerScheduel

type SafeTimerScheduel struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSafeTimerScheduel

func NewSafeTimerScheduel() *SafeTimerScheduel

func (*SafeTimerScheduel) CancelTimer

func (this *SafeTimerScheduel) CancelTimer(timerId uint32)

func (*SafeTimerScheduel) CreateTimer

func (this *SafeTimerScheduel) CreateTimer(delay int64, f func(v ...interface{}), args []interface{}) (uint32, error)

func (*SafeTimerScheduel) GetTriggerChannel

func (this *SafeTimerScheduel) GetTriggerChannel() chan *DelayCall

func (*SafeTimerScheduel) StartScheduelLoop

func (this *SafeTimerScheduel) StartScheduelLoop()

type Timer

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

func NewTimer

func NewTimer(durations time.Duration, f func(v ...interface{}), args []interface{}) *Timer

func (*Timer) GetDurations

func (this *Timer) GetDurations() time.Duration

func (*Timer) GetFunc

func (this *Timer) GetFunc() *DelayCall

func (*Timer) Run

func (this *Timer) Run()

Jump to

Keyboard shortcuts

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