subprocesses

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 4 Imported by: ? modules, 0 packages

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

Overview

Package subprocesses keeps track of concurrent processes, for coordination of cleanly shutting down systems of goroutines. This is a stripped-down version of errgroup.Group, motivated by the fact that allowing a single process to shut down the entire system by returning an error is quite fragile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Subprocesses

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

func (*Subprocesses) BlockForAtMost

func (s *Subprocesses) BlockForAtMost(ctx context.Context, d time.Duration, f func(context.Context)) (ok bool)

BlockForAtMost invokes f and blocks for at most duration d before returning, regardless of whether f finished or not, or the passed in ctx is cancelled. If f finished, returns true. Otherwise, returns false.

func (*Subprocesses) BlockForAtMostMany

func (s *Subprocesses) BlockForAtMostMany(ctx context.Context, d time.Duration, fs ...func(context.Context)) (ok bool, oks []bool)

BlockForAtMostMany invokes all fs in parallel and blocks for at most duration d before returning, regardless of whether all fs finished or not, or the passed in ctx is cancelled. If all fs finished, returns true, [true, ..., true]. Otherwise, returns false, and a boolean slice indicating which fs timed out.

func (*Subprocesses) Go

func (s *Subprocesses) Go(f func())

Go calls the given function in a new goroutine.

func (*Subprocesses) RepeatWithCancel

func (s *Subprocesses) RepeatWithCancel(name string, interval time.Duration, ctx context.Context, f func())

RepeatWithCancel repeats f with the specified interval. Cancel if ctx.Done is signaled

func (*Subprocesses) Wait

func (s *Subprocesses) Wait()

Wait blocks until all function calls from the Go method have returned.

Jump to

Keyboard shortcuts

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