/// <summary> /// Iterate over all labels in the label buffer. /// </summary> /// <param name="consumer"> function to be called for each label. </param> public void ForEach(IntObjConsumer <string> consumer) { var counterId = 0; for (int i = 0, capacity = MetaDataBuffer.Capacity; i < capacity; i += METADATA_LENGTH) { var recordStatus = MetaDataBuffer.GetIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { var label = LabelValue(i); consumer(counterId, label); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }
/// <summary> /// Iterate over all the metadata in the buffer. /// </summary> /// <param name="metaData"> function to be called for each metadata record. </param> public void ForEach(MetaData metaData) { var counterId = 0; for (int i = 0, capacity = MetaDataBuffer.Capacity; i < capacity; i += METADATA_LENGTH) { var recordStatus = MetaDataBuffer.GetIntVolatile(i); if (RECORD_UNUSED == recordStatus) { break; } if (RECORD_ALLOCATED == recordStatus) { var typeId = MetaDataBuffer.GetInt(i + TYPE_ID_OFFSET); var label = MetaDataBuffer.GetStringUtf8(i + LABEL_OFFSET); IDirectBuffer keyBuffer = new UnsafeBuffer(MetaDataBuffer, i + KEY_OFFSET, MAX_KEY_LENGTH); metaData(counterId, typeId, keyBuffer, label); } counterId++; } }
/// <summary> /// Get the state for a given counter id as a volatile read. /// </summary> /// <param name="counterId"> to be read. </param> /// <returns> the current state of the counter. </returns> /// <seealso cref="RECORD_UNUSED"></seealso> /// <seealso cref="RECORD_ALLOCATED"></seealso> /// <seealso cref="RECORD_RECLAIMED"></seealso> public int GetCounterState(int counterId) { ValidateCounterId(counterId); return(MetaDataBuffer.GetIntVolatile(MetaDataOffset(counterId))); }