예제 #1
0
        public MemoryPoolImpl(int processorCount)
        {
            this.processorCount = processorCount;
            var allocSize = this.processorCount * ChunksPerBucket * default(TSize).GetChunkSize();

            leasing = new Leasing(processorCount);

            memory   = new T[allocSize];
            gcHandle = GCHandle.Alloc(memory, GCHandleType.Pinned);
        }
예제 #2
0
        Owner?Lease(int bucketId, int chunkCount, int retries)
        {
            var index = bucketId;

            var lease = Leasing.Lease(ref leasing, index, chunkCount, retries);

            if (lease >= 0)
            {
                return(new Owner(this, (byte)bucketId, (byte)chunkCount, (byte)lease));
            }

            return(default);
예제 #3
0
 public static void Release(ref Leasing leasing, int index, int continousItems, short lease) =>
 Release(ref leasing.masks[index + 1].Value, continousItems, lease);
예제 #4
0
 public static long Lease(ref Leasing leasing, int index, int continousItems, int retries) => Lease(ref leasing.masks[index + 1].Value, continousItems, retries);