C# Class ServerToolkit.BufferManagement.BufferPool

Provides a pool of buffers that can be used to efficiently allocate memory for asynchronous socket operations
Inheritance: IBufferPool
显示文件 Open project: tenor/ServerToolkit Class Usage Examples

Private Properties

Property Type Description
GetFilledBuffer IBuffer
GetSingleSlabPool bool
SetSingleSlabPool void
TryAllocateBlocksInSlabs long
TryFreeSlabs void

Public Methods

Method Description
BufferPool ( long slabSize, int initialSlabs, int subsequentSlabs ) : System

Initializes a new instance of the BufferPool class

GetBuffer ( long size ) : IBuffer

Creates a buffer of the specified size

GetBuffer ( long size, byte filledWith ) : IBuffer

Creates a buffer of the specified size, filled with the contents of a specified byte array

Private Methods

Method Description
GetFilledBuffer ( IList allocatedBlocks, byte filledWith ) : IBuffer

Helper method that gets a filled buffer constructed from a list of memory blocks

GetSingleSlabPool ( ) : bool
SetSingleSlabPool ( bool value ) : void
TryAllocateBlocksInSlabs ( long totalLength, int maxBlocks, IMemorySlab slabs, List &allocatedBlocks ) : long

Helper method that searches for free blocks in an array of slabs and returns allocated blocks

TryFreeSlabs ( ) : void

Searches for empty slabs and frees one if there are more than InitialSlabs number of slabs.

Method Details

BufferPool() public method

Initializes a new instance of the BufferPool class
public BufferPool ( long slabSize, int initialSlabs, int subsequentSlabs ) : System
slabSize long Length, in bytes, of a slab in the BufferPool
initialSlabs int Number of slabs to create initially
subsequentSlabs int Number of additional slabs to create at a time
return System

GetBuffer() public method

Creates a buffer of the specified size
public GetBuffer ( long size ) : IBuffer
size long Buffer size, in bytes
return IBuffer

GetBuffer() public method

Creates a buffer of the specified size, filled with the contents of a specified byte array
public GetBuffer ( long size, byte filledWith ) : IBuffer
size long Buffer size, in bytes
filledWith byte Byte array to copy to buffer
return IBuffer