Pārlūkot izejas kodu

Short-circuit the fast path without locking

Evan Huus 11 gadi atpakaļ
vecāks
revīzija
c7ef7e79cd
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  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 {