Photon .NET Client API 4.1.4.8

Public Member Functions | Properties | List of all members
ExitGames.Client.Photon.ByteArraySlicePool Class Reference

Tiered pool for ByteArraySlices. Reduces the allocations once enough slices are available. More...

Public Member Functions

 ByteArraySlicePool ()
 Creates a new pool. More...
 
ByteArraySlice Acquire (byte[] buffer, int offset=0, int count=0)
 Get a ByteArraySlice from pool. This overload handles user supplied byte[] and byte count and can be used as a non-boxing alternative to ArraySegment<byte>. More...
 
ByteArraySlice Acquire (int minByteCount)
 Get byte[] wrapper from pool. This overload accepts a bytecount and will return a wrapper with a byte[] that size or greater. More...
 
bool Release (ByteArraySlice slice)
 Releasing a ByteArraySlice, will put it back into the pool, if it was acquired from one. More...
 
void ClearPools (int lower=0, int upper=int.MaxValue)
 Clears all pool items with byte array sizes between lower and upper inclusively. More...
 

Properties

int?? MinStackIndex [get, set]
 Requests for buffers smaller than 2^minStackIndex will use 2^minStackIndex. This value avoids allocations of smaller rarely used buffers. Set this to a lower value if you will never need sizes larger than byte[2^minStackIndex] More...
 
int AllocationCounter [get]
 Count of allocations this pool did. More...
 

Detailed Description

Tiered pool for ByteArraySlices. Reduces the allocations once enough slices are available.

Constructor & Destructor Documentation

◆ ByteArraySlicePool()

ExitGames.Client.Photon.ByteArraySlicePool.ByteArraySlicePool ( )
inline

Creates a new pool.

Member Function Documentation

◆ Acquire() [1/2]

ByteArraySlice ExitGames.Client.Photon.ByteArraySlicePool.Acquire ( byte[]  buffer,
int  offset = 0,
int  count = 0 
)
inline

Get a ByteArraySlice from pool. This overload handles user supplied byte[] and byte count and can be used as a non-boxing alternative to ArraySegment<byte>.

◆ Acquire() [2/2]

ByteArraySlice ExitGames.Client.Photon.ByteArraySlicePool.Acquire ( int  minByteCount)
inline

Get byte[] wrapper from pool. This overload accepts a bytecount and will return a wrapper with a byte[] that size or greater.

◆ ClearPools()

void ExitGames.Client.Photon.ByteArraySlicePool.ClearPools ( int  lower = 0,
int  upper = int.MaxValue 
)
inline

Clears all pool items with byte array sizes between lower and upper inclusively.

Use this if you sent some unusually large RaiseEvents and believe the buffers of that size will not be needed again, and you would like to free up the buffer memory.

◆ Release()

bool ExitGames.Client.Photon.ByteArraySlicePool.Release ( ByteArraySlice  slice)
inline

Releasing a ByteArraySlice, will put it back into the pool, if it was acquired from one.

Parameters
sliceThe ByteArraySlice to return to the pool.
Returns
True if this slice was returned to some pool. False if not.

Property Documentation

◆ AllocationCounter

int ExitGames.Client.Photon.ByteArraySlicePool.AllocationCounter
get

Count of allocations this pool did.

◆ MinStackIndex

int?? ExitGames.Client.Photon.ByteArraySlicePool.MinStackIndex
getset

Requests for buffers smaller than 2^minStackIndex will use 2^minStackIndex. This value avoids allocations of smaller rarely used buffers. Set this to a lower value if you will never need sizes larger than byte[2^minStackIndex]


The documentation for this class was generated from the following file: