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