timedexecutor

package
v0.0.0-...-25ef478 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

	// DontWaitForShutdown causes the TimedExecutor to not wait for all tasks to be executed before returning from the
	// Shutdown method.
	DontWaitForShutdown timedqueue.ShutdownFlag = 1 << 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(t *TimedExecutor)

Option is the type for functional options of the TimedExecutor.

func WithMaxQueueSize

func WithMaxQueueSize(maxSize int) Option

WithMaxQueueSize is an Option for the TimedExecutor that allows to specify a maxSize of the underlying queue.

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, opts ...Option) (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