thread

package
v0.0.0-...-c1449ee Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncCall

func AsyncCall(caller AsyncCaller, callback base.Callback, f func(), checking ...func() bool)

func AsyncCallDelay

func AsyncCallDelay(caller AsyncCaller, callback base.Callback, delay time.Duration, f func(), checking ...func() bool)

func GoCall

func GoCall(caller AsyncCaller, callback base.Callback, f func(), checking ...func() bool)

func GoCall2

func GoCall2(callback base.Callback, f func(), checking ...func() bool)

func SyncByHandler

func SyncByHandler(handler AsyncHandler, impl func(), timeout time.Duration) base.Result

func SyncByHandlerD

func SyncByHandlerD(handler AsyncHandler, impl func() any,
	timeout time.Duration) (base.Result, any)

func SyncCall

func SyncCall(impl func(callback base.Callback), timeout time.Duration) base.Result

func SyncCloseByHandler

func SyncCloseByHandler(handler AsyncHandler, impl func(), timeout time.Duration) base.Result

Types

type AsyncCaller

type AsyncCaller interface {
	IsInited() bool
	GetHandler() AsyncHandler
}

type AsyncHandler

type AsyncHandler interface {
	// IsCurrentInWorker 当前执行(协程)是否为工作队列本身
	//	(该方法性能不佳,不能频繁调用)
	IsCurrentInWorker() bool

	// Post 向工作队列投递任务
	Post(f func()) base.Result

	// PostDelayed 延期向工作队列投递任务
	PostDelayed(f func(), delay time.Duration) base.Result
}

type AsyncWorker

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

func NewAsyncWorker

func NewAsyncWorker(ownerName string) *AsyncWorker

func (*AsyncWorker) IsCurrentInWorker

func (w *AsyncWorker) IsCurrentInWorker() bool

IsCurrentInWorker 当前执行(协程)是否为工作队列本身

(该方法性能不佳,不能频繁调用)

func (*AsyncWorker) NotifyQuit

func (w *AsyncWorker) NotifyQuit() base.Result

NotifyQuit 通知工作队列退出

func (*AsyncWorker) Post

func (w *AsyncWorker) Post(f func()) base.Result

Post 向工作队列投递任务

func (*AsyncWorker) PostDelayed

func (w *AsyncWorker) PostDelayed(f func(), delay time.Duration) base.Result

PostDelayed 延期向工作队列投递任务

func (*AsyncWorker) RunInNewThreadUntilReady

func (w *AsyncWorker) RunInNewThreadUntilReady() base.Result

RunInNewThreadUntilReady 创建一个新协程运行当前工作队列

(阻塞当前执行,直到工作队列准备就绪)

func (*AsyncWorker) RunInNewThreadUntilReady2

func (w *AsyncWorker) RunInNewThreadUntilReady2(listenPanic bool, abort bool) base.Result

func (*AsyncWorker) RunLoop

func (w *AsyncWorker) RunLoop() base.Result

RunLoop 在当前协程中运行工作队列

(将阻塞当前执行,直到调用`stop`)

func (*AsyncWorker) SetTaskMaxLimit

func (w *AsyncWorker) SetTaskMaxLimit(max int) *AsyncWorker

func (*AsyncWorker) StopUntilQuit

func (w *AsyncWorker) StopUntilQuit(timeout time.Duration) base.Result

StopUntilQuit 通知工作队列退出

(将阻塞当前执行,直到队列中`立即型`任务都执行完并退出)

type Sync

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

func NewSync

func NewSync() *Sync

func (*Sync) Close

func (s *Sync) Close()

func (*Sync) Notify

func (s *Sync) Notify() base.Result

func (*Sync) NotifyWithData

func (s *Sync) NotifyWithData(data any) base.Result

func (*Sync) Reset

func (s *Sync) Reset()

func (*Sync) Wait

func (s *Sync) Wait() (base.Result, any)

func (*Sync) WaitWithTimeout

func (s *Sync) WaitWithTimeout(timeout time.Duration) (base.Result, any)

Jump to

Keyboard shortcuts

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