Documentation
¶
Overview ¶
`timed` is a global `timer` instance, that tick is 1ms. wheel size is 512, use [ants](https://github.com/panjf2000/ants) goroutine pool.
Deprecated: As of v0.7.0, the same functionality is now provided by timer, and those implementations
Index ¶
- func AddTask(task *Task) errordeprecated
- func Start()deprecated
- func Started() booldeprecated
- func Stop()deprecated
- func TaskCounter() int64deprecated
- func TickMs() int64deprecated
- func Timer() *timer.Timerdeprecated
- func WheelSize() intdeprecated
- type Job
- type JobFunc
- type Task
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start
deprecated
func Start()
Start the timer.
Deprecated: As of v0.7.0, use timer.Start instead.
func Stop
deprecated
func Stop()
Stop the timer.
Deprecated: As of v0.7.0, use timer.Stop instead.
func TaskCounter
deprecated
func TaskCounter() int64
TaskCounter return the total number of tasks.
Deprecated: As of v0.7.0, use timer.TaskCounter instead.
func Timer
deprecated
added in
v0.7.0
Timer return the default timer.
Deprecated: As of v0.7.0, use timer.DefaultTimer instead.
Example ¶
fmt.Println(Started())
Start()
_, _ = AfterFunc(100*time.Millisecond, func() {
fmt.Println(100)
})
canceledTaskThenAddAgain := NewTask(1100 * time.Millisecond).WithJobFunc(func() {
fmt.Println("canceled then add again")
})
_ = AddTask(canceledTaskThenAddAgain)
canceledTaskThenAddAgain.Cancel()
_ = AddTask(NewTask(1025 * time.Millisecond).WithJobFunc(func() {
fmt.Println(200)
}))
_ = AddTask(canceledTaskThenAddAgain)
time.Sleep(time.Second + time.Millisecond*200)
Stop()
Output: true 100 200 canceled then add again
Types ¶
Click to show internal directories.
Click to hide internal directories.