Example #1
0
 public HeapPageAllocator(ILoggerFactory logFactory, IAllocator allocator, int heapIndex)
 {
     _logFactory = logFactory;
     _logger     = _logFactory.CreateLogger <HeapPageAllocator>();
     Assert.Range(heapIndex, 0, 16);
     _heapIndex    = (uint)heapIndex;
     _allocations  = new PagedObjectPool <HeapPagePointer>(allocator);
     _allocator    = allocator;
     _desiredSizes = ((int)Math.Pow(2, _heapIndex) * 16384);
     _allocations.Take();
 }
Example #2
0
        public void ShouldReturnSameIdButDifferentVersion()
        {
            using var memory = new DynamicAllocator(_logFactory);
            using var pool   = new PagedObjectPool <int>(memory);
            pool.Take();
            var id = pool.Take();

            pool.Return(id);

            var newid = pool.Take();

            newid.ShouldNotBe(id);
            (newid & 0xffffff).ShouldBe(id & 0xffffff);
        }