C# Class Microsoft.AspNet.Server.Kestrel.Infrastructure.MemoryPool2

Used to allocate and distribute re-usable blocks of memory.
Inheritance: IDisposable
Show file Open project: Starcounter/KestrelHttpServer Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void
Lease ( int minimumSize ) : Microsoft.AspNet.Server.Kestrel.Infrastructure.MemoryPoolBlock2

Called to take a block from the pool.

Return ( Microsoft.AspNet.Server.Kestrel.Infrastructure.MemoryPoolBlock2 block ) : void

Called to return a block to the pool. Once Return has been called the memory no longer belongs to the caller, and Very Bad Things will happen if the memory is read of modified subsequently. If a caller fails to call Return and the block tracking object is garbage collected, the block tracking object's finalizer will automatically re-create and return a new tracking object into the pool. This will only happen if there is a bug in the server, however it is necessary to avoid leaving "dead zones" in the slab due to lost block tracking objects.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Private Methods

Method Description
AllocateSlab ( ) : void

Internal method called when a block is requested and the pool is empty. It allocates one additional slab, creates all of the block tracking objects, and adds them all to the pool.

Method Details

Dispose() public method

public Dispose ( ) : void
return void

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

Lease() public method

Called to take a block from the pool.
public Lease ( int minimumSize ) : Microsoft.AspNet.Server.Kestrel.Infrastructure.MemoryPoolBlock2
minimumSize int The block returned must be at least this size. It may be larger than this minimum size, and if so, /// the caller may write to the block's entire size rather than being limited to the minumumSize requested.
return Microsoft.AspNet.Server.Kestrel.Infrastructure.MemoryPoolBlock2

Return() public method

Called to return a block to the pool. Once Return has been called the memory no longer belongs to the caller, and Very Bad Things will happen if the memory is read of modified subsequently. If a caller fails to call Return and the block tracking object is garbage collected, the block tracking object's finalizer will automatically re-create and return a new tracking object into the pool. This will only happen if there is a bug in the server, however it is necessary to avoid leaving "dead zones" in the slab due to lost block tracking objects.
public Return ( Microsoft.AspNet.Server.Kestrel.Infrastructure.MemoryPoolBlock2 block ) : void
block Microsoft.AspNet.Server.Kestrel.Infrastructure.MemoryPoolBlock2 The block to return. It must have been acquired by calling Lease on the same memory pool instance.
return void