Class Allocator
Inheritance
Namespace: SuperNet.Netcode.Util
Assembly: cs.temp.dll.dll
Syntax
public sealed class Allocator
Constructors
Allocator()
Create a new allocator without any pooling.
Declaration
public Allocator()
Allocator(HostConfig)
Create a new allocator for a host.
Declaration
public Allocator(HostConfig config)
Parameters
Type | Name | Description |
---|---|---|
HostConfig | config | Configuration to use. |
Methods
CreateIV(Int32)
Allocate a new IV array for crypto.
Declaration
public byte[] CreateIV(int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | Length of the array. |
Returns
Type | Description |
---|---|
System.Byte[] | A new unused array. |
CreateKey(Int32)
Allocate a new key array for crypto.
Declaration
public byte[] CreateKey(int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | Length of the array. |
Returns
Type | Description |
---|---|
System.Byte[] | A new unused array. |
CreateMessage(Int32)
Allocate a new resizable array to store a single message.
Declaration
public byte[] CreateMessage(int minimumLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minimumLength | Minimum length of the returned array. |
Returns
Type | Description |
---|---|
System.Byte[] | A new unused array. |
CreatePacket(Int32)
Allocate a new short array to store a single packet.
Declaration
public byte[] CreatePacket(int minimumLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minimumLength | Minimum length of the returned array. |
Returns
Type | Description |
---|---|
System.Byte[] | A new unused array. |
CreateSent()
Allocate a new sent message storage used by peers.
Declaration
public Dictionary<Tuple<byte, ushort>, MessageSent> CreateSent()
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<Tuple<System.Byte, System.UInt16>, MessageSent> | A new unused sent message storage. |
CreateSet()
Allocate a new HashSet used by peers.
Declaration
public HashSet<Tuple<byte, ushort>> CreateSet()
Returns
Type | Description |
---|---|
HashSet<Tuple<System.Byte, System.UInt16>> | A new unused HashSet. |
CreateSocketArgs(EventHandler<SocketAsyncEventArgs>)
Declaration
public SocketAsyncEventArgs CreateSocketArgs(EventHandler<SocketAsyncEventArgs> callback)
Parameters
Type | Name | Description |
---|---|---|
EventHandler<SocketAsyncEventArgs> | callback |
Returns
Type | Description |
---|---|
SocketAsyncEventArgs |
ExpandMessage(Byte[], Int32, Int32)
Resize a message array to a larger size.
Declaration
public byte[] ExpandMessage(byte[] array, int offset, int length = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | Array to resize. |
System.Int32 | offset | Current array offset. |
System.Int32 | length | Length beyond the array offset to add. |
Returns
Type | Description |
---|---|
System.Byte[] | A new resized array with copied data. |
HashTableCreate(Int32)
Allocate a new hash table array for the LZF compressor.
Declaration
public long[] HashTableCreate(int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | Length of the array. |
Returns
Type | Description |
---|---|
System.Int64[] | A new unused array. |
HashTableReturn(Int64[])
Return a hash table array back to the pool.
Declaration
public void HashTableReturn(long[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Int64[] | array | Array to return. |
ReturnIV(ref Byte[])
Return an IV array back to the pool.
Declaration
public void ReturnIV(ref byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | Array to return. |
ReturnKey(ref Byte[])
Return a key array back to the pool.
Declaration
public void ReturnKey(ref byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | Array to return. |
ReturnMessage(ref Byte[])
Return a message array back to the pool.
Declaration
public void ReturnMessage(ref byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | Array to return. |
ReturnPacket(ref Byte[])
Return a packet array back to the pool.
Declaration
public void ReturnPacket(ref byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | Array to return. |
ReturnSent(ref Dictionary<Tuple<Byte, UInt16>, MessageSent>)
Return a sent message storage back to the pool.
Declaration
public void ReturnSent(ref Dictionary<Tuple<byte, ushort>, MessageSent> set)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<Tuple<System.Byte, System.UInt16>, MessageSent> | set | Sent message storage to return. |
ReturnSet(ref HashSet<Tuple<Byte, UInt16>>)
Return a HashSet back to the pool.
Declaration
public void ReturnSet(ref HashSet<Tuple<byte, ushort>> set)
Parameters
Type | Name | Description |
---|---|---|
HashSet<Tuple<System.Byte, System.UInt16>> | set | HashSet to return. |
ReturnSocketArgs(ref SocketAsyncEventArgs)
Declaration
public void ReturnSocketArgs(ref SocketAsyncEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
SocketAsyncEventArgs | args |
SequenceNew(Int32)
Allocate a new array to store message sequence for each channel.
Declaration
public int[] SequenceNew(int channels)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | channels | Number of channels. |
Returns
Type | Description |
---|---|
System.Int32[] | A new unused array. |
SequenceReturn(ref Int32[])
Return a sequence array back to the pool.
Declaration
public void SequenceReturn(ref int[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | array | Array to return. |
TokensNew(Int32)
Allocate a new cancellation token array for each channel.
Declaration
public CancellationTokenSource[] TokensNew(int channels)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | channels | Number of channels. |
Returns
Type | Description |
---|---|
CancellationTokenSource[] | A new unused array. |
TokensReturn(ref CancellationTokenSource[])
Return a cancellation token array back to the pool.
Declaration
public void TokensReturn(ref CancellationTokenSource[] array)
Parameters
Type | Name | Description |
---|---|---|
CancellationTokenSource[] | array | Array to return. |