threads

package
v0.0.0-...-72396ee Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoTry

func GoTry(f func(), catch func(interface{}), finally func())

GoTry 在新线程上跑

func SetUtilLog

func SetUtilLog(f func(err interface{}))

func TimeoutGo

func TimeoutGo(f func(), ticker time.Timer, timeoutfunc func())

func Try

func Try(f func(), catch func(interface{}), finally func())

Try C#中 的try

Types

type ThreadGo

type ThreadGo struct {
	Wg  sync.WaitGroup //等待
	Ctx context.Context
	Cal context.CancelFunc
}

ThreadGo 子协程管理计数,可以等子协程都完成 用它来管理所有开的协程,需要等这些线程都跑完

func NewThreadGo

func NewThreadGo() *ThreadGo

func NewThreadGoByGo

func NewThreadGoByGo(thgo *ThreadGo) *ThreadGo

func NewThreadGoBySub

func NewThreadGoBySub(ctx context.Context) *ThreadGo

func (*ThreadGo) CloseWait

func (this *ThreadGo) CloseWait()

func (*ThreadGo) Go

func (this *ThreadGo) Go(f func(ctx context.Context))

Go 在新前线程上跑

func (*ThreadGo) GoTry

func (this *ThreadGo) GoTry(f func(ctx context.Context), catch func(interface{}), finally func())

GoTry 在新协程上跑

func (*ThreadGo) SubGo

func (this *ThreadGo) SubGo(f func(ctx context.Context)) context.CancelFunc

SubGo返回可关掉的子协程

func (*ThreadGo) Try

func (this *ThreadGo) Try(f func(ctx context.Context), catch func(interface{}), finally func())

Try 在当前协程上跑

type ThreadRun

type ThreadRun struct {
	Chanresult chan func()
}

ThreadRun 新开协程的类有回调用的

func NewGo

func NewGo() *ThreadRun

NewGo 开一个新的协程对象

func NewGoRun

func NewGoRun(f func(), resultf func()) *ThreadRun

NewGoRun 开一个新的协程并运行它 在新协程上调用f ,resultf回到主线程的方法

func (*ThreadRun) Go

func (this *ThreadRun) Go(f func(), resultf func())

Go 在新协程上调用f ,resultf回到主线程的方法

Jump to

Keyboard shortcuts

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