Преглед на файлове

Short-circuit the fast path without locking

Evan Huus преди 11 години
родител
ревизия
c7ef7e79cd
променени са 1 файла, в които са добавени 6 реда и са изтрити 0 реда
  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 {