示例#1
0
        /// <summary>
        /// Iterate over the counters and provide the value and basic metadata.
        /// </summary>
        /// <param name="consumer"> for each allocated counter. </param>
        public void ForEach(CounterConsumer consumer)
        {
            int counterId = 0;

            for (int i = 0, capacity = MetaDataBuffer.Capacity; i < capacity; i += METADATA_LENGTH)
            {
                int recordStatus = MetaDataBuffer.GetIntVolatile(i);

                if (RECORD_ALLOCATED == recordStatus)
                {
                    consumer(ValuesBuffer.GetLongVolatile(CounterOffset(counterId)), counterId, LabelValue(i));
                }
                else if (RECORD_UNUSED == recordStatus)
                {
                    break;
                }

                counterId++;
            }
        }
示例#2
0
        /// <summary>
        /// Get the value for a given counter id as a volatile read.
        /// </summary>
        /// <param name="counterId"> to be read. </param>
        /// <returns> the current value of the counter. </returns>
        public long GetCounterValue(int counterId)
        {
            ValidateCounterId(counterId);

            return(ValuesBuffer.GetLongVolatile(CounterOffset(counterId)));
        }