-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
非阻塞在PoolOverload时进入等待队列 #56
Comments
为什么递归会用完 worker ?你是每一层递归都会调用 |
对,就是我遍历目录的时候,每一个子目录就再 if !cextinfo.IsDir() {
// ...
} else {
wg.Add(1)
err = p.Submit(func() {
buildTree(&cextinfo, errs, wg, p)
wg.Done()
})
if err != nil {
errs <- err
} |
你这个需求和 #55 大同小异,都是想把业务特性加到 再说了,这个需求也不合理,加入一个等待队列,这个队列长度又要怎么设置,超过了长度要怎么办?阻塞?丢弃?这不又和现在的情况一样了吗? 如果是长度无限制的话,那你完全可以直接使用 |
你说的有道理,但是如果长度无限制的话,那和自带的go关键字似乎没有区别?实际上我使用ants的原因就是在遍历很大的目录的时候,会出现内存占用过多的情况,因此希望能复用go程,那个 |
有区别啊,
|
OK懂了,谢谢 |
Is your feature request related to a problem? Please describe.
submit的函数如果是递归函数,则如果是阻塞模式,在递归深度较大的时候,会因为worker用光,程序直接被阻塞了,如果调整为非阻塞模式,则会在worker用光之后,后面的任务直接返回ErrPoolOverload而被舍弃。我是在遍历目录的时候遇到的这个问题。
Describe the solution you'd like
增加一个配置项,非阻塞模式下,可以选择增加一个等待队列,而不是舍弃。
Describe alternatives you've considered
增加一个channel,用于task完成后通知等待队列
The text was updated successfully, but these errors were encountered: