Documentation
¶
Overview ¶
包grpool实现了可重用的goroutine池。 md5:8908f4659795e87e
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddWithRecover ¶
func AddWithRecover(ctx context.Context, userFunc Func, recoverFunc RecoverFunc) error
AddWithRecover 将一个新的任务推送到默认池中,指定一个恢复函数。
可选的 `recoverFunc` 在执行 `userFunc` 时遇到任何 panic 时被调用。如果未传递或给定 `nil`,则忽略来自 `userFunc` 的 panic。任务将异步执行。 md5:4b448b4fd7caa604
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool 使用池管理goroutine。 md5:b07df489dc176e1c
func New ¶
New 创建并返回一个新的 goroutine 池对象。 参数 `limit` 用于限制最大 goroutine 数量, 默认情况下不限制。 md5:523f5833750663c7
func (*Pool) AddWithRecover ¶
AddWithRecover 将指定的恢复函数推送到队列中执行新任务。
可选的 `recoverFunc` 在执行 `userFunc` 时发生任何 panic 时被调用。如果未传递或给定 nil,它将忽略来自 `userFunc` 的 panic。任务将异步执行。 md5:764d1260466b9a5d
func (*Pool) Close ¶
func (p *Pool) Close()
Close 关闭goroutine池,导致所有goroutines退出。 md5:3d9c73ed9b0f4643
type RecoverFunc ¶
RecoverFunc 是一个带有上下文参数的池运行时panic恢复函数。 md5:745651d2d0aad841
Click to show internal directories.
Click to hide internal directories.