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); }
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);
public static void Release(ref Leasing leasing, int index, int continousItems, short lease) => Release(ref leasing.masks[index + 1].Value, continousItems, lease);
public static long Lease(ref Leasing leasing, int index, int continousItems, int retries) => Lease(ref leasing.masks[index + 1].Value, continousItems, retries);