runner

package
v0.0.0-...-23a64cd Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Example is provided with help by Gabriel Aszalos. Package runner manages the running and lifetime of a process.

Index

Constants

This section is empty.

Variables

View Source
var ErrInterrupt = errors.New("received interrupt")

ErrInterrupt is returned when an event from the OS is received.

View Source
var ErrTimeout = errors.New("received timeout")

ErrTimeout is returned when a value is received on the timeout channel.

Functions

This section is empty.

Types

type Runner

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

Runner runs a set of tasks within a given timeout and can be shut down on an operating system interrupt.

func New

func New(d time.Duration) *Runner

New returns a new ready-to-use Runner.

func (*Runner) Add

func (r *Runner) Add(tasks ...func(int))

Add attaches tasks to the Runner. A task is a function that takes an int ID.

func (*Runner) Start

func (r *Runner) Start() error

Start runs all tasks and monitors channel events.

Directories

Path Synopsis
This sample program demonstrates how to use a channel to monitor the amount of time the program is running and terminate the program if it runs too long.
This sample program demonstrates how to use a channel to monitor the amount of time the program is running and terminate the program if it runs too long.

Jump to

Keyboard shortcuts

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