safe

package
v0.0.8-tcp Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(f func(), panicCallback ...PanicCallback)

Call safely executes the provided function f and recovers from any panic, invoking the registered panic callbacks with the error and stack trace.

func CallCallBack

func CallCallBack(callbacks ...PanicCallback)

CallCallBack appends the zutils callbacks for safe.Call, it should be used only in the main package.

func Callback

func Callback(callbacks ...PanicCallback)

Callback appends the provided callbacks to both safe.Go and safe.Call.

func Go

func Go(f func(), panicCallback ...PanicCallback)

Go safely executes the provided function f in a new goroutine and recovers from any panic, invoking the registered panic callbacks with the error and stack trace. NOTE: don't use it in the function never return!!!!!

func GoCallBack

func GoCallBack(callbacks ...PanicCallback)

GoCallBack appends the zutils callbacks for safe.Go, it should be used only in the main package.

func Wait

func Wait()

Wait blocks until the WaitGroup counter is zero, meaning all goroutines have finished.

Types

type PanicCallback

type PanicCallback = func(err any, stack []byte)

PanicCallback defines a function type that takes an error and a stack trace as parameters.

Jump to

Keyboard shortcuts

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