timedexecutor

package
v0.0.0-...-5dd4785 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CancelPendingTasks defines a shutdown flag that causes all pending tasks to be canceled.
	CancelPendingTasks = timedqueue.CancelPendingElements

	// IgnorePendingTimeouts defines a shutdown flag, that makes the queue ignore the timeouts of the remaining queued
	// elements. Consecutive calls to Poll will immediately return these elements.
	IgnorePendingTimeouts = timedqueue.IgnorePendingTimeouts
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ScheduledTask

type ScheduledTask = timedqueue.QueueElement

ScheduledTask is

type ShutdownFlag

type ShutdownFlag = timedqueue.ShutdownFlag

ShutdownFlag defines the type of the optional shutdown flags.

type TimedExecutor

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

TimedExecutor defines a scheduler that executes tasks in the background at a given time. It does not spawn any additional goroutines for each task and executes the tasks sequentially (in each worker).

func New

func New(workerCount int) (timedExecutor *TimedExecutor)

New is the constructor for a TimedExecutor that creates a scheduler with a given number of workers that execute the scheduled tasks in parallel (whenever they become due).

func (*TimedExecutor) ExecuteAfter

func (t *TimedExecutor) ExecuteAfter(f func(), delay time.Duration) *ScheduledTask

ExecuteAfter executes the given function after the given delay.

func (*TimedExecutor) ExecuteAt

func (t *TimedExecutor) ExecuteAt(f func(), time time.Time) *ScheduledTask

ExecuteAt executes the given function at the given time.

func (*TimedExecutor) Shutdown

func (t *TimedExecutor) Shutdown(optionalShutdownFlags ...timedqueue.ShutdownFlag)

Shutdown shuts down the TimedExecutor and waits until the executor has shutdown gracefully.

func (*TimedExecutor) Size

func (t *TimedExecutor) Size() int

Size returns the amount of jobs that are currently scheduled for execution.

func (*TimedExecutor) WorkerCount

func (t *TimedExecutor) WorkerCount() int

WorkerCount returns the amount of background workers that this executor uses.

Jump to

Keyboard shortcuts

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