C# Class ServerToolkit.BufferManagement.BufferPool

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

Private Properties

Свойство Type Description
GetFilledBuffer IBuffer
GetSingleSlabPool bool
SetSingleSlabPool void
TryAllocateBlocksInSlabs long
TryFreeSlabs void

Méthodes publiques

Méthode 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

Méthode 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 méthode

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
Résultat System

GetBuffer() public méthode

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

GetBuffer() public méthode

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
Résultat IBuffer