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 02:52:42 UTC

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

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



##########
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:
       87行是否不再需要了




-- 
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