threading

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoSafe

func GoSafe(fn func())

GoSafe runs the given fn using another goroutine, recovers if fn panics.

func GoSafeCtx

func GoSafeCtx(ctx context.Context, fn func())

GoSafeCtx runs the given fn using another goroutine, recovers if fn panics with ctx.

func RoutineId

func RoutineId() uint64

RoutineId is only for debug, never use it in production.

func RunSafe

func RunSafe(fn func())

RunSafe runs the given fn, recovers if fn panics.

func RunSafeCtx

func RunSafeCtx(ctx context.Context, fn func())

RunSafeCtx runs the given fn, recovers if fn panics with ctx.

Types

type RoutineGroup

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

A RoutineGroup is used to group goroutines together and all wait all goroutines to be done.

func NewRoutineGroup

func NewRoutineGroup() *RoutineGroup

NewRoutineGroup returns a RoutineGroup.

func (*RoutineGroup) Run

func (g *RoutineGroup) Run(fn func())

Run runs the given fn in RoutineGroup. Don't reference the variables from outside, because outside variables can be changed by other goroutines

func (*RoutineGroup) RunSafe

func (g *RoutineGroup) RunSafe(fn func())

RunSafe runs the given fn in RoutineGroup, and avoid panics. Don't reference the variables from outside, because outside variables can be changed by other goroutines

func (*RoutineGroup) Wait

func (g *RoutineGroup) Wait()

Wait waits all running functions to be done.

Jump to

Keyboard shortcuts

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