rubyist/circuitbreaker — pull request #1 by willglynn (2014-07-23 17:30:10+00:00)
Title: Fix race conditions relating to failure count

The current code reads:

atomic.AddInt64(&cb.failures, 1)
//…
if cb.BreakerOpen != nil && cb.failures == cb.Threshold {
cb.BreakerOpen(cb, err)
}

It's possible for two threads to increment `cb.failures` before the `if`, resulting in neither thread invoking `BreakerOpen()`.