diff options
Diffstat (limited to 'Ryujinx.Common/Pools/ThreadStaticArray.cs')
-rw-r--r-- | Ryujinx.Common/Pools/ThreadStaticArray.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Ryujinx.Common/Pools/ThreadStaticArray.cs b/Ryujinx.Common/Pools/ThreadStaticArray.cs new file mode 100644 index 00000000..21434a02 --- /dev/null +++ b/Ryujinx.Common/Pools/ThreadStaticArray.cs @@ -0,0 +1,20 @@ +using System; + +namespace Ryujinx.Common.Pools +{ + public static class ThreadStaticArray<T> + { + [ThreadStatic] + private static T[] _array; + + public static ref T[] Get() + { + if (_array == null) + { + _array = new T[1]; + } + + return ref _array; + } + } +} |