Documentation
¶
Overview ¶
Package queue provides a task dispatcher that executes tasks sequentially in a queue.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher executes Task sequentially in run loop in Serve method.
func NewDispatcher ¶
func NewDispatcher(ctx context.Context) *Dispatcher
NewDispatcher creates a new Dispatcher with the given parent context and options.
func (*Dispatcher) AfterFunc ¶
func (d *Dispatcher) AfterFunc(duration time.Duration, f func()) task.Timer
AfterFunc enqueues f to TaskQueue after specified duration.
func (*Dispatcher) Serve ¶
func (d *Dispatcher) Serve() error
Serve execute Task(s) in loop. The return value of Serve is the error that caused the dispatcher to stop.
NOTE: This method is intended to be called from a single goroutine only. Concurrent calls from multiple goroutines may lead to race conditions.
Click to show internal directories.
Click to hide internal directories.