@@ -0,0 +1,2792 @@
+/*%0A * Copyright 2017 Real Logic Ltd.%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 */%0Apackage org.agrona.concurrent.status;%0A%0Aimport org.agrona.DirectBuffer;%0Aimport org.agrona.MutableDirectBuffer;%0Aimport org.agrona.concurrent.AtomicBuffer;%0A%0Aimport java.nio.charset.Charset;%0Aimport java.util.concurrent.locks.ReentrantLock;%0Aimport java.util.function.Consumer;%0A%0A/**%0A * A thread safe extension of %7B@link CountersManager%7D which allows intra-process read and write access to the same%0A * counters buffer. Note that inter-process access is not catered for.%0A */%0Apublic class ConcurrentCountersManager extends CountersManager%0A%7B%0A    private final ReentrantLock lock = new ReentrantLock();%0A%0A    public ConcurrentCountersManager(final AtomicBuffer metaDataBuffer, final AtomicBuffer valuesBuffer)%0A    %7B%0A        super(metaDataBuffer, valuesBuffer);%0A    %7D%0A%0A    public ConcurrentCountersManager(%0A        final AtomicBuffer metaDataBuffer,%0A        final AtomicBuffer valuesBuffer,%0A        final Charset labelCharset)%0A    %7B%0A        super(metaDataBuffer, valuesBuffer, labelCharset);%0A    %7D%0A%0A    public int allocate(final String label)%0A    %7B%0A        lock.lock();%0A        try%0A        %7B%0A            return super.allocate(label);%0A        %7D%0A        finally%0A        %7B%0A            lock.unlock();%0A        %7D%0A    %7D%0A%0A%0A    public int allocate(final String label, final int typeId, final Consumer%3CMutableDirectBuffer%3E keyFunc)%0A    %7B%0A        lock.lock();%0A        try%0A        %7B%0A            return super.allocate(label, typeId, keyFunc);%0A        %7D%0A        finally%0A        %7B%0A            lock.unlock();%0A        %7D%0A    %7D%0A%0A    public int allocate(%0A        final int typeId,%0A        final DirectBuffer keyBuffer,%0A        final int keyOffset,%0A        final int keyLength,%0A        final DirectBuffer labelBuffer,%0A        final int labelOffset,%0A        final int labelLength)%0A    %7B%0A        lock.lock();%0A        try%0A        %7B%0A            return super.allocate(typeId, keyBuffer, keyOffset, keyLength, labelBuffer, labelOffset, labelLength);%0A        %7D%0A        finally%0A        %7B%0A            lock.unlock();%0A        %7D%0A    %7D%0A%0A    public void free(final int counterId)%0A    %7B%0A        lock.lock();%0A        try%0A        %7B%0A            super.free(counterId);%0A        %7D%0A        finally%0A        %7B%0A            lock.unlock();%0A        %7D%0A    %7D%0A%7D%0A

Add ConcurrentCountersManager.