@@ -0,0 +1,2055 @@
+/*%0A * Copyright 2016 Timothy Brooks%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A */%0A%0Apackage net.uncontended.precipice.metrics.experimental;%0A%0Aimport net.uncontended.precipice.metrics.Allocator;%0Aimport net.uncontended.precipice.metrics.CircularBuffer;%0Aimport net.uncontended.precipice.metrics.IntervalIterator;%0Aimport net.uncontended.precipice.time.Clock;%0A%0Apublic class NewRoller%3CT%3E implements NewMetrics%3CT%3E %7B%0A%0A    private final Allocator%3CT%3E allocator;%0A    private final Clock clock;%0A    private final T total;%0A    private final CircularBuffer%3CT%3E buffer;%0A%0A    public NewRoller(T total, Allocator%3CT%3E allocator, CircularBuffer%3CT%3E buffer, Clock clock) %7B%0A        this.total = total;%0A        this.buffer = buffer;%0A        this.clock = clock;%0A        this.allocator = allocator;%0A    %7D%0A%0A    @Override%0A    public T current() %7B%0A        return buffer.getSlot(clock.nanoTime());%0A    %7D%0A%0A    @Override%0A    public T current(long nanoTime) %7B%0A        T current = buffer.getSlot(nanoTime);%0A        if (current == null) %7B%0A            T newCurrent = allocator.allocateNew();%0A            // TODO: Consider whether null is the correct return value%0A            buffer.putOrGet(nanoTime, newCurrent);%0A            current = allocator.allocateNew();%0A        %7D%0A        return current;%0A    %7D%0A%0A    @Override%0A    public T total() %7B%0A        return total;%0A    %7D%0A%0A    public IntervalIterator%3CT%3E intervals() %7B%0A        return intervals(clock.nanoTime());%0A    %7D%0A%0A    public IntervalIterator%3CT%3E intervals(long nanoTime) %7B%0A        return buffer.intervals(nanoTime, null);%0A    %7D%0A%7D%0A

Work on implementing possible new roller