"When the timer triggers, the inactive bucket is zeroed and swapped with the active bucket. Then the inactive bucket contains the number of successes and failures since the last time the timer triggered. Those numbers are used to evaluate the ejection criteria." - A50.
()
| 56 | // failures since the last time the timer triggered. Those numbers are used to |
| 57 | // evaluate the ejection criteria." - A50. |
| 58 | func (cc *callCounter) swap() { |
| 59 | ib := cc.inactiveBucket |
| 60 | *ib = bucket{} |
| 61 | ab := cc.activeBucket.Swap(ib) |
| 62 | cc.inactiveBucket = &bucket{ |
| 63 | numSuccesses: atomic.LoadUint32(&ab.numSuccesses), |
| 64 | numFailures: atomic.LoadUint32(&ab.numFailures), |
| 65 | } |
| 66 | } |