You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/04/30 03:07:55 UTC

[GitHub] [servicecomb-service-center] szt-sketch commented on a change in pull request #963: SCB-2259 Fix: Gopool should reuse worker with certainty

szt-sketch commented on a change in pull request #963:
URL: https://github.com/apache/servicecomb-service-center/pull/963#discussion_r623554607



##########
File path: pkg/gopool/goroutines.go
##########
@@ -81,10 +81,14 @@ func (g *Pool) execute(f func(ctx context.Context)) {
 func (g *Pool) Do(f func(context.Context)) *Pool {
 	defer log.Recover()
 	select {
-	case g.pending <- f: // block if workers are busy
-	case g.workers <- struct{}{}:
-		g.wg.Add(1)
-		go g.loop(f)
+	case g.pending <- f: // try to reuse worker first
+	default:
+		select {
+		case g.pending <- f: // block if workers are busy

Review comment:
       需要,当worker慢了都在负载中时,需要新任务等待worker空闲。 此时无法新创建worker




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org