safe

package
v0.0.0-...-b5ed4c6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(goroutine func())

Go create goroutine with default recover function

func GoWithRecovery

func GoWithRecovery(goroutine func(), customRecover func(args ...any))

GoWithRecovery create goroutine with custom recover function

Types

type NoCopy

type NoCopy struct{}

NoCopy prohibits the copying of struct objects sample: type Foo struct { noCopy } a go vet grammar check will prompt a warning

func (*NoCopy) Lock

func (*NoCopy) Lock()

Lock noop lock

func (*NoCopy) Unlock

func (*NoCopy) Unlock()

Unlock noop Unlock

type TaskManager

type TaskManager interface {
	io.Closer
	// Ctx get base context from TaskManger
	Ctx() context.Context
	// GoCtx start goroutine with context
	GoCtx(goroutine func(ctx context.Context))
}

TaskManager this Interface is designed to manage single-run tasks in the system the purpose of the design is to facilitate the unified management of coroutine and avoid its leakage all coroutine should be exited after CTX is cleared by cancel

func NewTaskManager

func NewTaskManager(parentCtx context.Context) TaskManager

NewTaskManager create new task manager with context

Jump to

Keyboard shortcuts

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