예제 #1
0
            public ArrayFreeList(
                int smallBlockSize,
                int largeBlockSize,
                int smallItemMaxBytes,
                SharedBlockArrayFreeList <T> sharedBlockLists,
                SharedBlockFreeList <object> sharedEmptySmallBlocksList,
                SharedBlockFreeList <object> sharedEmptyLargeBlocksList)
            {
                long sizeofT = SizeOf <T>();

                countInUse = 0;

                this.sharedEmptySmallBlocksList = sharedEmptySmallBlocksList;
                this.sharedEmptyLargeBlocksList = sharedEmptyLargeBlocksList;

                freeLists       = new SimpleFreeList <T[]> [32];
                largeStartIndex = -1;
                for (int i = 0; i < freeLists.Length; i++)
                {
                    bool large = sizeofT * (1L << i) > smallItemMaxBytes;
                    if ((largeStartIndex == -1) && large)
                    {
                        largeStartIndex = i;
                    }
                    freeLists[i] = new SimpleFreeList <T[]>(
                        large ? largeBlockSize : smallBlockSize,
                        sharedBlockLists[i],
                        large ? sharedEmptyLargeBlocksList : sharedEmptySmallBlocksList);
                }
            }
예제 #2
0
            public SharedBlockArrayFreeList(
                int smallBlockSize,
                int largeBlockSize,
                int smallItemMaxBytes)
            {
                long sizeofT = SizeOf <T>();

                freelists       = new SharedBlockFreeList <T[]> [32];
                largeStartIndex = -1;
                for (int i = 0; i < freelists.Length; i++)
                {
                    bool large = sizeofT * (1L << i) > smallItemMaxBytes;
                    if ((largeStartIndex == -1) && large)
                    {
                        largeStartIndex = i;
                    }
                    freelists[i] = new SharedBlockFreeList <T[]>(large ? largeBlockSize : smallBlockSize);
                }
            }
예제 #3
0
            public SimpleFreeList(
                int blockSize,
                SharedBlockFreeList <T> sharedFreeList,
                SharedBlockFreeList <object> sharedEmptyBlocksList)
            {
                Debug.Assert((blockSize & (blockSize - 1)) == 0); // must be integral power of 2

                this.sharedFreeItemsList   = sharedFreeList;
                this.sharedEmptyBlocksList = sharedEmptyBlocksList;

                this.blockSize = blockSize;

                this.currentFreeItemsBlock = null;
                this.countFree             = 0;
                this.countInUse            = 0;
                this.extraFreeItemsBlock   = null;

#if DEBUG
                this.freed = new Dictionary <object, bool>();
#endif
            }