class Concurrent::ThreadSafe::Util::Adder

A Ruby port of the Doug Lea’s jsr166e.LondAdder class version 1.8 available in public domain.

Original source code available here: gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166e/LongAdder.java?revision=1.8

One or more variables that together maintain an initially zero sum. When updates (method add) are contended across threads, the set of variables may grow dynamically to reduce contention. Method sum returns the current total combined across the variables maintaining the sum.

This class is usually preferable to single Atomic reference when multiple threads update a common sum that is used for purposes such as collecting statistics, not for fine-grained synchronization control. Under low update contention, the two classes have similar characteristics. But under high contention, expected throughput of this class is significantly higher, at the expense of higher space consumption.

@!visibility private