Introduce CustomEventHandler for more flexible invocation

This commit is contained in:
Sardelka9515
2023-02-15 11:38:02 +08:00
parent e4f432b593
commit e5f426690f
14 changed files with 182 additions and 73 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using GTA.Math;
namespace RageCoop.Core
@ -43,6 +44,11 @@ namespace RageCoop.Core
public unsafe sealed class BufferWriter : Buffer
{
/// <summary>
/// Gets a thread local instance of this writer
/// </summary>
public static readonly ThreadLocal<BufferWriter> ThreadLocal = new(() => new(4096));
public BufferWriter(int size)
{
Resize(size);
@ -184,6 +190,11 @@ namespace RageCoop.Core
public unsafe sealed class BufferReader : Buffer
{
/// <summary>
/// Gets a thread local instance of this reader
/// </summary>
public static readonly ThreadLocal<BufferReader> ThreadLocal = new(() => new());
/// <summary>
/// Initialize an empty instance, needs to call <see cref="Initialise(byte*, int)"/> before reading data
/// </summary>