subprocesses

package
v0.0.0-...-adbe570 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 4 Imported by: 0

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