runner

package
v0.0.0-...-3f48b55 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package runner 管理处理任务的运行和生命周期

Index

Constants

This section is empty.

Variables

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

ErrInterrupt 会在接收到操作系统的事件时返回

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

ErrTimeout 会在任务执行超时时返回

Functions

This section is empty.

Types

type Runner

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

Runner 在给定的超时时间内执行一组任务 并且在操作系统发送中断信号时结束这个任务

func New

func New(d time.Duration) *Runner

New 返回一个新的准备使用的 Runner

func (*Runner) Add

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

Add 将一个任务附加到Runner上,这个任务是一个接收一个int类型的ID作为参数的函数

func (*Runner) Start

func (r *Runner) Start() error

Start 执行所有任务,并监视通道事件

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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