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/29 15:11:29 UTC

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

szt-sketch opened a new pull request #963:
URL: https://github.com/apache/servicecomb-service-center/pull/963


   fix gopool reuse worker with certainty
   
   


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



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

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #963: SCB-2259 Fix: Gopool should reuse worker with certainty

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #963:
URL: https://github.com/apache/servicecomb-service-center/pull/963


   


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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
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