rubyist/circuitbreaker — pull request #2 by willglynn (2014-07-23 17:52:23+00:00)
Title: Replace racy half-open increment-if-zero with a compare-and-swap

The current code is racy:

if cb.halfOpens == 0 {
atomic.AddInt64(&cb.halfOpens, 1)
return halfopen
}

This commit replaces the increment-if-zero with a compare-and-swap-if-zero, ensuring that only one thread will return `halfopen`, which seems to be the intent of the current code.