示例#1
0
        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);
            }
        }
示例#2
0
 public BufferReservation(BufferPool pool, LOHBuffer buffer)
 {
     this.pool   = pool;
     this.buffer = buffer;
 }
示例#3
0
 internal void Release(LOHBuffer buffer)
 {
     buffer.InUse = false;
     guard.Release();
 }