// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Threading; namespace FASTER.core { class PendingFlushList { const int maxSize = 8; const int maxRetries = 10; public PageAsyncFlushResult[] list; public PendingFlushList() { list = new PageAsyncFlushResult[maxSize]; } public void Add(PageAsyncFlushResult t) { int retries = 0; do { for (int i = 0; i < maxSize; i++) { if (list[i] == default) { if (Interlocked.CompareExchange(ref list[i], t, default) == default) { return; } } } } while (retries++ < maxRetries); throw new Exception("Unable to add item to list"); } public bool RemoveAdjacent(long address, out PageAsyncFlushResult request) { for (int i=0; i