goroutinepool

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoroutinePool

type GoroutinePool[T, R interface{}] struct {
	// contains filtered or unexported fields
}

func New

func New[T, R interface{}](f func(arg T) R, t int, queueLen int) *GoroutinePool[T, R]

New 创建一个协程池,T 为参数类型,R 为返回值类型。参数 f 为执行函数。参数 t 为并发协程数。 协程池执行函数 f 的返回值类型必须为 R。 协程池执行函数 f 的参数类型必须为 T。 协程池等待队列的长度为 queueLen。

func (*GoroutinePool[T, R]) Results

func (p *GoroutinePool[T, R]) Results() <-chan Result[T, R]

Results 获取结果的channel

func (*GoroutinePool[T, R]) Shutdown

func (p *GoroutinePool[T, R]) Shutdown()

Shutdown 关闭等待队列,并等待所有协程执行完毕

func (*GoroutinePool[T, R]) Submit

func (p *GoroutinePool[T, R]) Submit(args T)

type Result

type Result[T, R interface{}] struct {
	Result R
	Arg    T
	Err    error
}

Jump to

Keyboard shortcuts

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