Documentation
¶
Overview ¶
Package dqueue implements thread safe deferred queue for tasks to be executed in future after some delay
Index ¶
- type Handler
- func (h *Handler[T]) Dump() (ret []Task[T])
- func (h *Handler[T]) ExecuteAfter(payload T, after time.Duration) (ok bool)
- func (h *Handler[T]) ExecuteAt(payload T, when time.Time) (ok bool)
- func (h *Handler[T]) Get() (task Task[T], ready bool)
- func (h *Handler[T]) Len() int
- func (h *Handler[T]) Prune()
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler[T comparable] struct { // contains filtered or unexported fields }
Handler is deferred queue handler used to store and retrieve (in time) tasks to be executed
func (*Handler[T]) Dump ¶
Dump returns copy of contents of the queue in sorted manner, leaving queue intact.
func (*Handler[T]) ExecuteAfter ¶
ExecuteAfter schedules task for execution on after time.Duration provided, it returns true, if task is accepted.
func (*Handler[T]) ExecuteAt ¶
ExecuteAt schedules task for execution on time desired, it returns true, if task is accepted.
func (*Handler[T]) Get ¶
Get extracts one of tasks from queue in thread safe manner. If second argument is true, it means task is ready to be executed and is removed from queue. If there are no ready tasks in queue, first argument is zero Task struct and second one - false.
type Task ¶
type Task[T comparable] struct { ExecuteAt time.Time Payload T }
Task is element describing things to be done in future