Forráskód Böngészése

Short-circuit the fast path without locking

Evan Huus 11 éve
szülő
commit
c7ef7e79cd
1 módosított fájl, 6 hozzáadás és 0 törlés
  1. 6 0
      breaker/breaker.go

+ 6 - 0
breaker/breaker.go

@@ -64,6 +64,12 @@ func (b *Breaker) Run(x func() error) error {
 		return x()
 	}()
 
+	if result == nil && panicValue == nil && state == closed {
+		// short-circuit the normal, success path without contending
+		// on the lock
+		return nil
+	}
+
 	b.processResult(result, panicValue)
 
 	if panicValue != nil {