mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
d3d12: Do not detach garbage collection thread
Thanks Neko for the tips.
This commit is contained in:
parent
cf1c86bb2f
commit
9cb7339067
@ -35,16 +35,11 @@ void SetGetD3DGSFrameCallback(GetGSFrameCb2 value)
|
||||
|
||||
GarbageCollectionThread::GarbageCollectionThread()
|
||||
{
|
||||
m_isThreadAlive = true;
|
||||
m_askForTermination = false;
|
||||
m_worker = std::thread([this]() {
|
||||
while (m_isThreadAlive)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
while (!m_askForTermination)
|
||||
{
|
||||
CHECK_EMU_STATUS;
|
||||
|
||||
if (!lock)
|
||||
{
|
||||
lock.lock();
|
||||
@ -65,23 +60,26 @@ GarbageCollectionThread::GarbageCollectionThread()
|
||||
}
|
||||
cv.wait(lock);
|
||||
}
|
||||
}
|
||||
m_isThreadAlive = false;
|
||||
});
|
||||
m_worker.detach();
|
||||
}
|
||||
|
||||
GarbageCollectionThread::~GarbageCollectionThread()
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_askForTermination = true;
|
||||
while (m_isThreadAlive);
|
||||
cv.notify_one();
|
||||
}
|
||||
m_worker.join();
|
||||
}
|
||||
|
||||
void GarbageCollectionThread::pushWork(std::function<void()>&& f)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_queue.push(f);
|
||||
cv.notify_all();
|
||||
}
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
void GarbageCollectionThread::waitForCompletion()
|
||||
|
@ -215,8 +215,7 @@ struct DataHeap
|
||||
*/
|
||||
struct GarbageCollectionThread
|
||||
{
|
||||
bool m_isThreadAlive;
|
||||
bool m_askForTermination;
|
||||
std::atomic<bool> m_askForTermination;
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable cv;
|
||||
std::queue<std::function<void()> > m_queue;
|
||||
|
Loading…
Reference in New Issue
Block a user