coroutine

package
v0.7.21 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoAndWait

func GoAndWait(fns ...func() error) error

1. 多协程并发执行时,一个协程抛出panic会导致所有协程全部退出,一个协程的panic只能该协程调用recover捕获,所以每个协程都要执行defer func() { recover() }() 2. 如果我们有批量的任务需要执行,肯定通过并发调用来提高性能,同时我们不希望其中一个调用失败就导致所有的任务都退出,而是要继续执行完其它的任务,封装co.GoAndWait接口

Types

type Pool

type Pool struct {
	*ants.Pool
	// contains filtered or unexported fields
}

func NewPool

func NewPool(poolCapacity int, taskCapacity int, printf func(formatter string, args ...any)) *Pool

func (*Pool) Run

func (pool *Pool) Run(task func())

func (*Pool) Wait added in v0.6.3

func (pool *Pool) Wait()

Jump to

Keyboard shortcuts

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