1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

UpdateF, dx reinit

This commit is contained in:
Brian Fiete 2022-05-15 08:00:55 -07:00
parent fa2cb7ba56
commit e87bf5b029
24 changed files with 1029 additions and 415 deletions

View file

@ -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)