Documentation ¶
Overview ¶
Package timer defines the interface for timer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OperationItem ¶
type OperationItem[T comparable] struct { // OpType specifies the operation type. OpType OpType // ID specifies the task unique id. ID T // RunTime specifies the task run time. RunTime time.Time }
OperationItem specifies one task in timer.
type Operator ¶
type Operator[T comparable] interface { // Start starts the timer Start() // Stop stops the timer Stop() // Register binds a handler for one operation type. // This function should be invoked before all Add. Register(opType OpType, handler func(id T)) // Add adds a new task to timer. Add(opType OpType, id T, delay time.Duration) error // Get gets the task from timer. Get(opType OpType, id T) *OperationItem[T] // GetAll gets all active tasks from timer. GetAll() []*OperationItem[T] // Remove removes the task from timer. Remove(opType OpType, id T) error }
Operator is the interface for timer.
Click to show internal directories.
Click to hide internal directories.