소스 검색

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 {