1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-19 16:40:26 +02:00

Fixed GC race condition starting an autodelete thread

This commit is contained in:
Brian Fiete 2020-08-31 11:29:11 -07:00
parent 43660fb633
commit b3354ee635
5 changed files with 39 additions and 7 deletions

View file

@ -131,6 +131,8 @@ namespace System
public extern static void SetCollectFreeThreshold(int freeBytes); // -1 to disable, 0 to trigger collection after every single free. Defaults to 64MB
[CallingConvention(.Cdecl)]
public extern static void SetMaxPausePercentage(int maxPausePercentage); // 0 = disabled. Defaults to 20.
[CallingConvention(.Cdecl)]
extern static void AddPendingThread(void* internalThread);
#else
public static void Collect(bool async = true) {}
private static void MarkAllStaticMembers() {}
@ -141,6 +143,7 @@ namespace System
public static void SetAutoCollectPeriod(int periodMS) {}
public static void SetCollectFreeThreshold(int freeBytes) {}
public static void SetMaxPausePercentage(int maxPausePercentage) {}
extern static void AddPendingThread(void* internalThreadInfo) {}
#endif
static void MarkDerefedObject(Object* obj)

View file

@ -41,6 +41,8 @@ namespace System.Threading
static void Thread_SetInternalThread(Object thread, void* internalThread)
{
if (internalThread != null)
GC.[Friend]AddPendingThread(internalThread);
((Thread)thread).[Friend]mInternalThread = (int)internalThread;
}