public IBufferRegistration GetBuffer()
        {
            guard.Wait();
            // can get buffer
            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;
 }
 private void Release(LOHBuffer buffer)
 {
     buffer.InUse = false;
     guard.Release();
 }