コード例 #1
0
 private static void UseObjectsInPool(GitIndexProjection.ObjectPool <object> pool, int count)
 {
     for (int i = 0; i < count; i++)
     {
         pool.GetNew().ShouldNotBeNull();
     }
 }
コード例 #2
0
 private static GitIndexProjection.ObjectPool <object> CreateExpandedPool()
 {
     GitIndexProjection.ObjectPool <object> pool = new GitIndexProjection.ObjectPool <object>(new MockTracer(), AllocationSize, objectCreator: () => new object());
     UseObjectsInPool(pool, DefaultObjectsToUse);
     pool.Size.ShouldEqual(PoolSizeAfterUsingDefault);
     return(pool);
 }
コード例 #3
0
 public void ShrinkKeepsUsedObjectsPlusPercent()
 {
     GitIndexProjection.ObjectPool <object> pool = new GitIndexProjection.ObjectPool <object>(new MockTracer(), AllocationSize, objectCreator: () => new object());
     UseObjectsInPool(pool, 20);
     pool.Size.ShouldEqual(AllocationSize);
     pool.Shrink();
     pool.Size.ShouldEqual(Convert.ToInt32(20 * 1.1));
 }
コード例 #4
0
 public void FreeToZeroAllocatesMinimumSizeNextGet()
 {
     GitIndexProjection.ObjectPool <object> pool = new GitIndexProjection.ObjectPool <object>(new MockTracer(), AllocationSize, objectCreator: () => new object());
     pool.FreeAll();
     pool.Shrink();
     pool.Size.ShouldEqual(0);
     UseObjectsInPool(pool, 1);
     pool.Size.ShouldEqual(AllocationSize);
 }
コード例 #5
0
 public void FreeKeepsPoolSize()
 {
     GitIndexProjection.ObjectPool <object> pool = CreateExpandedPool();
     pool.FreeAll();
     pool.Size.ShouldEqual(DefaultShrinkSize);
     UseObjectsInPool(pool, DefaultObjectsToUse);
     UseObjectsInPool(pool, 15);
     pool.Size.ShouldEqual(PoolSizeAfterExpandingAfterShrinking);
     pool.FreeAll();
     pool.Size.ShouldEqual(PoolSizeAfterExpandingAfterShrinking);
 }