예제 #1
0
 public MemoryPool(ILocalNode localNode, ILogger logger)
 {
     _localNode              = localNode;
     _logger                 = logger.ForContext("SourceContext", nameof(MemoryPool));
     _pooledTransactions     = new PooledList <TransactionModel>(MaxMemoryPoolTransactions);
     _pooledSeenTransactions = new PooledList <string>(MaxMemoryPoolSeenTransactions);
     Observable.Timer(TimeSpan.Zero, TimeSpan.FromHours(1)).Subscribe(x =>
     {
         _pooledSeenTransactions.RemoveRange(0, Count());
     });
 }
예제 #2
0
 /// <summary>
 /// Removes items in the <see cref="DrawOperations"/> collection from the specified index
 /// to the end.
 /// </summary>
 /// <param name="first">The index of the first operation to be removed.</param>
 public void TrimDrawOperations(int first)
 {
     if (first < _drawOperations?.Count)
     {
         EnsureDrawOperationsCreated();
         for (int i = first; i < _drawOperations.Count; i++)
         {
             _drawOperations[i].Dispose();
         }
         _drawOperations.RemoveRange(first, _drawOperations.Count - first);
     }
 }
예제 #3
0
 /// <summary>
 /// Removes items in the <see cref="Children"/> collection from the specified index
 /// to the end.
 /// </summary>
 /// <param name="first">The index of the first child to be removed.</param>
 public void TrimChildren(int first)
 {
     if (first < _children?.Count)
     {
         EnsureChildrenCreated();
         for (int i = first; i < _children.Count; i++)
         {
             _children[i].Dispose();
         }
         _children.RemoveRange(first, _children.Count - first);
     }
 }
예제 #4
0
        public void Remove_Range(int listLength, int index, int count)
        {
            PooledList <T> list       = GenericListFactory(listLength);
            PooledList <T> beforeList = list.ToPooledList();

            list.RemoveRange(index, count);
            Assert.Equal(list.Count, listLength - count); //"Expected them to be the same."
            for (int i = 0; i < index; i++)
            {
                Assert.Equal(list[i], beforeList[i]); //"Expected them to be the same."
            }

            for (int i = index; i < count - (index + count); i++)
            {
                Assert.Equal(list[i], beforeList[i + count]); //"Expected them to be the same."
            }

            list.Dispose();
            beforeList.Dispose();
        }