threading

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCanceled = context.Canceled
	ErrTimeout  = context.DeadlineExceeded
)

Functions

func DoWithTimeout

func DoWithTimeout(fn func() error, timeout time.Duration, opts ...FxOption) error

func GoSafe

func GoSafe(fn func())

func Rescue

func Rescue(cleanups ...func())

func RoutineId

func RoutineId() uint64

Only for debug, never use it in production

func RunSafe

func RunSafe(fn func())

Types

type FxOption

type FxOption func() context.Context

func WithContext

func WithContext(ctx context.Context) FxOption

type RoutineGroup

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

func NewRoutineGroup

func NewRoutineGroup() *RoutineGroup

func (*RoutineGroup) Run

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

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())

Don't reference the variables from outside, because outside variables can be changed by other goroutines

func (*RoutineGroup) Wait

func (g *RoutineGroup) Wait()

type TaskRunner

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

func NewTaskRunner

func NewTaskRunner(concurrency int) *TaskRunner

func (*TaskRunner) Schedule

func (rp *TaskRunner) Schedule(task func())

Jump to

Keyboard shortcuts

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