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 ¶
GoSafeCtx runs the given fn using another goroutine, recovers if fn panics with ctx.
func RunSafeCtx ¶
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 (*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.