twitter/ostrich — pull request #68 by daggerrz (2014-03-29 22:34:51+00:00)
Title: Add FastCounter (LongAdder) explicitly in order to reduce compatibility issues

This is another approach to the `LongAdder` implementation (see https://github.com/twitter/ostrich/pull/67). Instead of retrofitting the default counter with the faster version and thus break the atomic semantics. This version instead adds a new class `FastCounter` and `StatsCollection` keeps a separate map for each of them. Invoking the old `incr(): Long` methods will work as before, but using the new `increment(): Unit` will be using the fast implementation.

Getting the counter values from `StatsCollection.getCounters()` will return the values of both collections of counters, but to get individual counters `StatsCollection.getCounter()` or `StatsCollection.getFastCounter()` must be called and the counter type known up front. This is not that pretty but it can't really be resolved any other way while keeping binary compatibility. `StatsCollection.getFastCounter()` returns a new trait `Counting` just for forward compatibility's sake (sorry, `Counter` would be so much better, but it's taken :)).

I have not added any deprecation warnings to this version, but let me know what you think.