コード例 #1
0
        public void Set(
            IWorkerSocket socket, BufferAllocation bufferAllocation,
            Action release)
        {
            _socket = socket;
            _release = release;

            _awaitable.EventArgs
                      .SetBuffer(
                          bufferAllocation.Buffer,
                          bufferAllocation.Offset, bufferAllocation.Size);

            Closed = false;
        }
コード例 #2
0
        public BufferAllocation Allocate()
        {
            BufferAllocation allocation;

            if (!_allocationPool.TryPop(out allocation))
            {
                // create allocation upto the max allowed
                if (_allocationIndex == MaximumAllocations)
                    throw new BufferMaximumAllocationsExceededException();

                allocation = new BufferAllocation(
                    _buffers,
                    _allocationIndex*AllocatedBufferSize,
                    AllocatedBufferSize);

                _allocationIndex++;

                return allocation;
            }

            return allocation;
        }
コード例 #3
0
 public void Deallocate(BufferAllocation allocation)
 {
     _allocationPool.Push(allocation);
 }