coroutine_pool

package
v0.0.0-...-68eb72d Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPool = NewCoroutinePool()

创建默认池

View Source
var ErrServerStop = fmt.Errorf("服务已经停止禁止添加新任务")

Functions

This section is empty.

Types

type CoroutinePool

type CoroutinePool struct {
	ServerCtx context.Context
	// contains filtered or unexported fields
}

CoroutinePool 支持平滑关闭的协程池

func NewCoroutinePool

func NewCoroutinePool() *CoroutinePool

func (*CoroutinePool) Go

func (s *CoroutinePool) Go(f func()) error

Go 需要手动捕获panic,如果不捕获啥也不提示

func (*CoroutinePool) Stop

func (s *CoroutinePool) Stop()

Stop 停止添加信息的go任务

func (*CoroutinePool) Wait

func (s *CoroutinePool) Wait()

Wait 等待已经添加的任务执行完成

func (*CoroutinePool) Wait2

func (s *CoroutinePool) Wait2(e time.Duration) (err error)

Wait2 等待已经添加的任务执行完成

func (*CoroutinePool) WithMaxGoroutines

func (s *CoroutinePool) WithMaxGoroutines(n int)

WithMaxGoroutines 限制了池中goroutines的数量。 默认为无限制。如果n<1,则会出现恐慌。

Jump to

Keyboard shortcuts

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