Parcourir la source

accelerate one task execution

Darien Raymond il y a 7 ans
Parent
commit
eafe580be4
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      common/task/task.go

+ 5 - 0
common/task/task.go

@@ -20,6 +20,11 @@ func (c *executionContext) executeTask() error {
 		return nil
 	}
 
+	// Reuse current goroutine if we only have one task to run.
+	if len(c.tasks) == 1 && c.ctx == nil {
+		return c.tasks[0]()
+	}
+
 	ctx := context.Background()
 
 	if c.ctx != nil {