mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
UpdateF, dx reinit
This commit is contained in:
parent
fa2cb7ba56
commit
e87bf5b029
24 changed files with 1029 additions and 415 deletions
|
@ -1429,6 +1429,9 @@ bool BFGC::ScanThreads()
|
|||
thread = mThreadList[threadIdx++];
|
||||
}
|
||||
|
||||
if (thread->mExcluded)
|
||||
continue;
|
||||
|
||||
if (!thread->mRunning)
|
||||
{
|
||||
AutoCrit autoCrit(mCritSect);
|
||||
|
@ -2367,11 +2370,12 @@ void BFGC::SuspendThreads()
|
|||
auto curThreadId = GetCurrentThreadId();
|
||||
for (auto thread : mThreadList)
|
||||
{
|
||||
if ((thread->mThreadId != curThreadId) && (thread->mRunning) && (thread->WantsSuspend()))
|
||||
if ((thread->mThreadId != curThreadId) && (!thread->mExcluded) && (thread->mRunning) && (thread->WantsSuspend()))
|
||||
{
|
||||
// We must lock this before suspending so we can access mStackMarkableObjects
|
||||
// Otherwise we could deadlock
|
||||
thread->mCritSect.Lock();
|
||||
thread->mSuspended = true;
|
||||
|
||||
BfpThreadResult result;
|
||||
BfpThread_Suspend(thread->mThreadHandle, &result);
|
||||
|
@ -2386,11 +2390,12 @@ void BFGC::ResumeThreads()
|
|||
auto curThreadId = GetCurrentThreadId();
|
||||
for (auto thread : mThreadList)
|
||||
{
|
||||
if ((thread->mThreadId != curThreadId) && (thread->mRunning) && (thread->WantsSuspend()))
|
||||
if ((thread->mThreadId != curThreadId) && (thread->mSuspended) && (thread->mRunning) && (thread->WantsSuspend()))
|
||||
{
|
||||
// Previously locked in SuspendThreads
|
||||
thread->mCritSect.Unlock();
|
||||
|
||||
thread->mSuspended = false;
|
||||
BfpThread_Resume(thread->mThreadHandle, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -2743,6 +2748,16 @@ void BFGC::SetMaxRawDeferredObjectFreePercentage(intptr maxPercentage)
|
|||
mMaxRawDeferredObjectFreePercentage = maxPercentage;
|
||||
}
|
||||
|
||||
void BFGC::ExcludeThreadId(intptr threadId)
|
||||
{
|
||||
Beefy::AutoCrit autoCrit(mCritSect);
|
||||
for (auto thread : mThreadList)
|
||||
{
|
||||
if (thread->mThreadId == threadId)
|
||||
thread->mExcluded = true;
|
||||
}
|
||||
}
|
||||
|
||||
using namespace bf::System;
|
||||
|
||||
void GC::Run()
|
||||
|
@ -2832,6 +2847,11 @@ BFRT_EXPORT void bf::System::GC::SetMaxRawDeferredObjectFreePercentage(intptr ma
|
|||
gBFGC.SetMaxRawDeferredObjectFreePercentage(maxPercentage);
|
||||
}
|
||||
|
||||
BFRT_EXPORT void bf::System::GC::ExcludeThreadId(intptr threadId)
|
||||
{
|
||||
gBFGC.ExcludeThreadId(threadId);
|
||||
}
|
||||
|
||||
#else // BF_GC_SUPPORTED
|
||||
|
||||
void* BfObjectAllocate(intptr size, bf::System::Type* type)
|
||||
|
|
|
@ -181,6 +181,8 @@ public:
|
|||
intptr mStackStart;
|
||||
intptr mLastStackPtr;
|
||||
bool mRunning;
|
||||
bool mExcluded;
|
||||
bool mSuspended;
|
||||
Beefy::Array<bf::System::Object*> mStackMarkableObjects;
|
||||
|
||||
ThreadInfo()
|
||||
|
@ -192,6 +194,8 @@ public:
|
|||
mTEB = NULL;
|
||||
mStackStart = NULL;
|
||||
mRunning = true;
|
||||
mExcluded = false;
|
||||
mSuspended = false;
|
||||
}
|
||||
|
||||
~ThreadInfo();
|
||||
|
@ -424,6 +428,7 @@ public:
|
|||
void SetCollectFreeThreshold(int freeBytes);
|
||||
void SetMaxPausePercentage(int maxPausePercentage);
|
||||
void SetMaxRawDeferredObjectFreePercentage(intptr maxPercentage);
|
||||
void ExcludeThreadId(intptr threadId);
|
||||
};
|
||||
|
||||
extern BFGC gBFGC;
|
||||
|
@ -466,7 +471,7 @@ namespace bf
|
|||
BFRT_EXPORT static void StopCollecting();
|
||||
BFRT_EXPORT static void AddStackMarkableObject(Object* obj);
|
||||
BFRT_EXPORT static void RemoveStackMarkableObject(Object* obj);
|
||||
BFRT_EXPORT static void AddPendingThread(void* internalThreadInfo);
|
||||
BFRT_EXPORT static void AddPendingThread(void* internalThreadInfo);
|
||||
|
||||
public:
|
||||
BFRT_EXPORT static void Shutdown();
|
||||
|
@ -488,6 +493,7 @@ namespace bf
|
|||
BFRT_EXPORT static void SetCollectFreeThreshold(intptr freeBytes);
|
||||
BFRT_EXPORT static void SetMaxPausePercentage(intptr maxPausePercentage);
|
||||
BFRT_EXPORT static void SetMaxRawDeferredObjectFreePercentage(intptr maxPercentage);
|
||||
BFRT_EXPORT static void ExcludeThreadId(intptr threadId);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue