package
Version:
v0.7.21
Opens a new window with list of versions in this module.
Published: Nov 8, 2024
License: Apache-2.0
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
1. 多协程并发执行时,一个协程抛出panic会导致所有协程全部退出,一个协程的panic只能该协程调用recover捕获,所以每个协程都要执行defer func() { recover() }()
2. 如果我们有批量的任务需要执行,肯定通过并发调用来提高性能,同时我们不希望其中一个调用失败就导致所有的任务都退出,而是要继续执行完其它的任务,封装co.GoAndWait接口
type Pool struct {
*ants.Pool
}
func NewPool(poolCapacity int, taskCapacity int, printf func(formatter string, args ...any)) *Pool
func (pool *Pool) Run(task func())
Source Files
¶
Click to show internal directories.
Click to hide internal directories.