public void Set( IWorkerSocket socket, BufferAllocation bufferAllocation, Action release) { _socket = socket; _release = release; _awaitable.EventArgs .SetBuffer( bufferAllocation.Buffer, bufferAllocation.Offset, bufferAllocation.Size); Closed = false; }
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; }
public void Deallocate(BufferAllocation allocation) { _allocationPool.Push(allocation); }