runtimei

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 11 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()

type TaskPool

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

func NewTaskPool

func NewTaskPool(size int) *TaskPool

func (*TaskPool) Add

func (p *TaskPool) Add(delta int)

Add 新增一个执行

func (*TaskPool) Done

func (p *TaskPool) Done()

Done 执行完成减一

func (*TaskPool) Exec

func (t *TaskPool) Exec(f func())

func (*TaskPool) Wait

func (t *TaskPool) Wait()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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