mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
Fixed GC race condition starting an autodelete thread
This commit is contained in:
parent
43660fb633
commit
b3354ee635
5 changed files with 39 additions and 7 deletions
|
@ -1389,7 +1389,17 @@ bool BFGC::ScanThreads()
|
|||
while (true)
|
||||
{
|
||||
ThreadInfo* thread = NULL;
|
||||
|
||||
///
|
||||
{
|
||||
AutoCrit autoCrit(mCritSect);
|
||||
for (auto& kv : mPendingThreads)
|
||||
{
|
||||
MarkFromGCThread(kv.mValue->mThread);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
{
|
||||
AutoCrit autoCrit(mCritSect);
|
||||
if (threadIdx >= mThreadList.size())
|
||||
|
@ -1927,7 +1937,7 @@ void BFGC::ThreadStopped(BfDbgInternalThread* thread)
|
|||
void BFGC::ThreadStarted()
|
||||
{
|
||||
Beefy::AutoCrit autoCrit(mCritSect);
|
||||
|
||||
|
||||
ThreadInfo* thread = new ThreadInfo();
|
||||
thread->mRunning = true;
|
||||
thread->mThreadHandle = BfpThread_GetCurrent();
|
||||
|
@ -1938,6 +1948,7 @@ void BFGC::ThreadStarted()
|
|||
thread->CalcStackStart();
|
||||
|
||||
mThreadList.Add(thread);
|
||||
mPendingThreads.Remove(thread->mThreadId);
|
||||
|
||||
ThreadInfo::sCurThreadInfo = thread;
|
||||
}
|
||||
|
@ -2028,6 +2039,14 @@ void BFGC::RemoveStackMarkableObject(bf::System::Object* obj)
|
|||
threadInfo->mStackMarkableObjects.RemoveAtFast(stackIdx);
|
||||
}
|
||||
|
||||
void BFGC::AddPendingThread(BfInternalThread* internalThread)
|
||||
{
|
||||
if (internalThread->mThread == 0)
|
||||
return;
|
||||
Beefy::AutoCrit autoCrit(mCritSect);
|
||||
mPendingThreads.TryAdd(internalThread->mThreadId, internalThread);
|
||||
}
|
||||
|
||||
void BFGC::Shutdown()
|
||||
{
|
||||
if (mShutdown)
|
||||
|
@ -2710,6 +2729,11 @@ void GC::AddStackMarkableObject(Object* obj)
|
|||
gBFGC.AddStackMarkableObject(obj);
|
||||
}
|
||||
|
||||
void GC::AddPendingThread(void* internalThreadInfo)
|
||||
{
|
||||
gBFGC.AddPendingThread((BfInternalThread*)internalThreadInfo);
|
||||
}
|
||||
|
||||
void GC::RemoveStackMarkableObject(Object* obj)
|
||||
{
|
||||
gBFGC.RemoveStackMarkableObject(obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue