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)
Click to show internal directories.
Click to hide internal directories.