gotimer

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 5 Imported by: 0

README

gotimer

time wheel for golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPrecision ...
	DefaultPrecision = time.Millisecond * 100
	// DefaultBaseMask ...
	DefaultBaseMask = 10
)
View Source
var (
	// ElementCntPerBucket ...
	ElementCntPerBucket = []int64{256, 64, 64, 64, 64}
)

Functions

func After

func After(d time.Duration) <-chan struct{}

After ...

func AfterFunc

func AfterFunc(d time.Duration, f func())

AfterFunc ...

func ResetMask

func ResetMask(mask int, stop ...bool)

ResetMask ...

func ResetPrecision

func ResetPrecision(precision time.Duration, stop ...bool)

ResetPrecision ...

func ResetPrecisionAndMask

func ResetPrecisionAndMask(precision time.Duration, mask int, stop ...bool)

ResetPrecisionAndMask ...

Types

type TaskList

type TaskList struct {
	sync.Mutex
	Elems *list.List
	// contains filtered or unexported fields
}

TaskList ...

func (*TaskList) AddChan

func (ml *TaskList) AddChan(d time.Duration) (c chan struct{}, f func())

AddChan ...

func (*TaskList) AddTask

func (ml *TaskList) AddTask(d time.Duration, f func())

AddTask ...

type TaskNode

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

TaskNode ...

type TimeWheel

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

TimeWheel ...

func NewTimeWheel

func NewTimeWheel(basetime time.Duration, intervals []int64) *TimeWheel

NewTimeWheel : basetime is min precision.intervals the number of each bucket.

func (*TimeWheel) After

func (p *TimeWheel) After(d time.Duration) <-chan struct{}

After ...

func (*TimeWheel) AfterFunc

func (p *TimeWheel) AfterFunc(d time.Duration, f func())

AfterFunc ...

func (*TimeWheel) Stop

func (p *TimeWheel) Stop()

Stop ...

func (*TimeWheel) UpdateOffset

func (p *TimeWheel) UpdateOffset(index int) int64

UpdateOffset ...

type Timer

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

Timer ...

func NewTimer

func NewTimer(baseTime ...time.Duration) *Timer

NewTimer ...

func (*Timer) After

func (p *Timer) After(d time.Duration) <-chan struct{}

After ...

func (*Timer) AfterFunc

func (p *Timer) AfterFunc(d time.Duration, task func())

AfterFunc ...

func (*Timer) Stop

func (p *Timer) Stop()

Stop ...

type XTimerHandler

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

XTimerHandler ...

func NewXTimerHandler

func NewXTimerHandler(precision time.Duration, buckets int) *XTimerHandler

NewXTimerHandler ...

func (*XTimerHandler) After

func (p *XTimerHandler) After(d time.Duration) <-chan struct{}

After ...

func (*XTimerHandler) AfterFunc

func (p *XTimerHandler) AfterFunc(d time.Duration, task func())

AfterFunc ...

func (*XTimerHandler) Stop

func (p *XTimerHandler) Stop()

Stop ...

Jump to

Keyboard shortcuts

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