timewheel

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Remain

type Remain interface {
	// Expired return expired time in int64 UnixNano
	Expired() int64
}

Remain for timing wheel task

type SimpleWheel

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

SimpleWheel a simple multi-level timing wheel

func NewSimpleTimeWheel

func NewSimpleTimeWheel(tick time.Duration, size int64, pool int) *SimpleWheel

NewSimpleTimeWheel return a timimg wheel with size * tick, and executor pool(goroutine) size

func (*SimpleWheel) After

func (w *SimpleWheel) After(d time.Duration, task func()) *Task

After add a task to timing wheel with delay time.

func (*SimpleWheel) AfterRemain

func (w *SimpleWheel) AfterRemain(r Remain, task func()) *Task

AfterRemain add a task to timing wheel with Remain object.

func (*SimpleWheel) Done

func (w *SimpleWheel) Done() int64

Done atomic get sum of done task.

func (*SimpleWheel) Start

func (w *SimpleWheel) Start()

Start timing wheel tick

func (*SimpleWheel) Stop

func (w *SimpleWheel) Stop()

Stop timing wheel tick

type Task

type Task struct {
	Remain
	// contains filtered or unexported fields
}

Task wrapper a delayed execute function.

func (*Task) Stop

func (t *Task) Stop() (stopped bool)

Stop task and remove, return true if removed.

Jump to

Keyboard shortcuts

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