public IBufferRegistration GetBuffer() { guard.Wait(); lock (buffers) { IBufferRegistration freeBuffer = null; foreach (LOHBuffer buffer in buffers) { if (!buffer.InUse) { buffer.InUse = true; freeBuffer = new BufferReservation(this, buffer); } } if (freeBuffer == null) { var buffer = new LOHBuffer(); buffer.InUse = true; buffers.Add(buffer); freeBuffer = new BufferReservation(this, buffer); } return(freeBuffer); } }
public BufferReservation(BufferPool pool, LOHBuffer buffer) { this.pool = pool; this.buffer = buffer; }
internal void Release(LOHBuffer buffer) { buffer.InUse = false; guard.Release(); }