コード例 #1
0
ファイル: MemoryPoolImpl.cs プロジェクト: luyikk/ZYSOCKET-V
        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
ファイル: MemoryPoolImpl.cs プロジェクト: luyikk/ZYSOCKET-V
        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);