/** * Iterate over the counters and provide the value and basic metadata. * * @param consumer for each allocated counter. */ public void forEach(final CounterConsumer consumer) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { consumer.accept(valuesBuffer.getLongVolatile(counterOffset(counterId)), counterId, labelValue(i)); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }
/** * Iterate over the counters and provide the value and basic metadata. * * @param consumer for each allocated counter. */ public void forEach(final CounterConsumer consumer) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { consumer.accept(valuesBuffer.getLongVolatile(counterOffset(counterId)), counterId, labelValue(i)); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }