mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 07:05:50 +03:00
Make Helper calls threadsafe
This commit is contained in:
parent
4c353264cb
commit
ecdf217d08
@ -9,8 +9,8 @@ internal static class Helpers
|
|||||||
{
|
{
|
||||||
public const int MaxStringSize = 1024 * 32;
|
public const int MaxStringSize = 1024 * 32;
|
||||||
|
|
||||||
private static IntPtr[] MemoryPool;
|
[ThreadStatic] private static IntPtr[] MemoryPool;
|
||||||
private static int MemoryPoolIndex;
|
[ThreadStatic] private static int MemoryPoolIndex;
|
||||||
|
|
||||||
public static unsafe IntPtr TakeMemory()
|
public static unsafe IntPtr TakeMemory()
|
||||||
{
|
{
|
||||||
@ -38,8 +38,8 @@ public static unsafe IntPtr TakeMemory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static byte[][] BufferPool;
|
[ThreadStatic] private static byte[][] BufferPool;
|
||||||
private static int BufferPoolIndex;
|
[ThreadStatic] private static int BufferPoolIndex;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a buffer. This will get returned and reused later on.
|
/// Returns a buffer. This will get returned and reused later on.
|
||||||
@ -49,9 +49,9 @@ public static byte[] TakeBuffer( int minSize )
|
|||||||
if ( BufferPool == null )
|
if ( BufferPool == null )
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// The pool has 8 items.
|
// The pool has 4 items.
|
||||||
//
|
//
|
||||||
BufferPool = new byte[8][];
|
BufferPool = new byte[4][];
|
||||||
|
|
||||||
for ( int i = 0; i < BufferPool.Length; i++ )
|
for ( int i = 0; i < BufferPool.Length; i++ )
|
||||||
BufferPool[i] = new byte[ 1024 * 128 ];
|
BufferPool[i] = new byte[ 1024 * 128 ];
|
||||||
|
Loading…
Reference in New Issue
Block a user