/// <summary> /// Pre touch memory pages so they are faulted in to be available before access. /// </summary> public void PreTouch() { const int value = 0; int pageSize = LogBufferDescriptor.PageSize(_logMetaDataBuffer); UnsafeBuffer atomicBuffer = new UnsafeBuffer(); foreach (MappedByteBuffer buffer in _mappedByteBuffers) { atomicBuffer.Wrap(buffer.Pointer, 0, (int)buffer.Capacity); for (int i = 0, length = atomicBuffer.Capacity; i < length; i += pageSize) { atomicBuffer.CompareAndSetInt(i, value, value); } } }
/// <summary> /// Compare and set the value of the current active term count. /// </summary> /// <param name="metaDataBuffer"> containing the metadata. </param> /// <param name="expectedTermCount"> value of the active term count expected in the log </param> /// <param name="updateTermCount"> value of the active term count to be updated in the log </param> /// <returns> true if successful otherwise false. </returns> public static bool CasActiveTermCount(UnsafeBuffer metaDataBuffer, int expectedTermCount, int updateTermCount) { return(metaDataBuffer.CompareAndSetInt(LOG_ACTIVE_TERM_COUNT_OFFSET, expectedTermCount, updateTermCount)); }