private IList <ContentHashWithLastAccessTimeAndReplicaCount> GetUnpinnedHashesAndCompilePinnedSize( Context context, IEnumerable <ContentHashWithLastAccessTimeAndReplicaCount> hashesToPurge, PinnedSizeChecker pinnedSizeChecker, PurgeResult purgeResult) { long totalPinnedSize = 0; // Compile aggregate pinnedSize for the fail faster case var unpinnedHashes = new List <ContentHashWithLastAccessTimeAndReplicaCount>(); foreach (var hashInfo in hashesToPurge) { var pinnedSize = pinnedSizeChecker(context, hashInfo.ContentHash); if (pinnedSize >= 0) { totalPinnedSize += pinnedSize; } else { unpinnedHashes.Add(hashInfo); } } purgeResult.MergePinnedSize(totalPinnedSize); return(unpinnedHashes); }
/// <summary> /// Finish setting up distributed eviction. /// </summary> public void InitializeDistributedEviction( UpdateContentWithLastAccessTimeAsync updateMetadataFunc, Tracer tracer, PinnedSizeChecker pinnedSizeChecker, NagleQueue <ContentHash> reregisterHashQueue) { Contract.Assert(updateMetadataFunc != null); Contract.Assert(pinnedSizeChecker != null); Contract.Assert(tracer != null); Contract.Assert(reregisterHashQueue != null); UpdateContentWithLastAccessTimeAsync = updateMetadataFunc; Tracer = tracer; PinnedSizeChecker = pinnedSizeChecker; ReregisterHashQueue = reregisterHashQueue; IsInitialized = true; }