runtimei

package
v0.0.0-...-1f4ee57 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TickerInterval = time.Millisecond * 50

TickerInterval defines the interval used by the ticker in Check* functions.

Functions

func CheckContext

func CheckContext(ctx context.Context, t *testing.T) func()

CheckContext snapshots the currently-running goroutines and returns a function to be run at the end of tests to see whether any goroutines leaked.

func GetCallerFrame

func GetCallerFrame(skip int) (frame runtime.Frame, ok bool)

func GetFuncName

func GetFuncName(i interface{}) string

GetFuncName return the function name

func GoID

func GoID() (id uint64)

GoID returns the ID of current goroutine.

Types

type NumGoroutine

type NumGoroutine struct {
	context.Context
	context.CancelFunc
	// contains filtered or unexported fields
}

监测子协程是否跑完,需要代码层面的配合 一点都不优雅 没什么优不优雅,这就像wg.Add(1)

func New

func New(callback func()) *NumGoroutine

func (*NumGoroutine) Cancel

func (ng *NumGoroutine) Cancel()

func (*NumGoroutine) End

func (ng *NumGoroutine) End()

func (*NumGoroutine) Monitor

func (ng *NumGoroutine) Monitor(fn func())

有没有可能父协程return后,子协程还没开始执行

func (*NumGoroutine) Start

func (ng *NumGoroutine) Start()

Jump to

Keyboard shortcuts

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