C# Class SocketServers.SmartBufferPool

Lock-free buffer pool implementation, it is more simple solution than classic memory manager algorithms (e.g. buddy memory manager). But it should use less extra calculation for allocation and freeing buffers. It like "smart" buffer pool, it slices desired sizes, and do not free slices but put it in pool for further using. So big buffer should be sliced for concrete application.
Mostrar archivo Open project: vf1/serversockets Class Usage Examples

Public Properties

Property Type Description
ExtraMemoryUsage long
InitialMemoryUsage long
MaxBuffersCount long
MaxMemoryUsage long

Public Methods

Method Description
Allocate ( int size ) : ArraySegment
Free ( ArraySegment segment ) : void
SmartBufferPool ( int maxMemoryUsageMb, int initialSizeMb, int extraBufferSizeMb ) : System

Private Methods

Method Description
GetAllocated ( int size, int &index, int &offset ) : bool
GetBitOffset ( int size ) : int
NewBuffer ( long size ) : byte[]

Method Details

Allocate() public method

public Allocate ( int size ) : ArraySegment
size int
return ArraySegment

Free() public method

public Free ( ArraySegment segment ) : void
segment ArraySegment
return void

SmartBufferPool() public method

public SmartBufferPool ( int maxMemoryUsageMb, int initialSizeMb, int extraBufferSizeMb ) : System
maxMemoryUsageMb int
initialSizeMb int
extraBufferSizeMb int
return System

Property Details

ExtraMemoryUsage public_oe property

public long ExtraMemoryUsage
return long

InitialMemoryUsage public_oe property

public long InitialMemoryUsage
return long

MaxBuffersCount public_oe property

public long MaxBuffersCount
return long

MaxMemoryUsage public_oe property

public long MaxMemoryUsage
return long