MTVU: Use Thread wrapper

This commit is contained in:
Connor McLaughlin 2022-05-07 21:08:08 +10:00 committed by refractionpcsx2
parent 457ec7f6f5
commit bb9a551318
2 changed files with 6 additions and 9 deletions

View File

@ -100,23 +100,23 @@ VU_Thread::~VU_Thread()
void VU_Thread::Open()
{
if (m_thread.joinable())
if (m_thread.Joinable())
return;
Reset();
semaEvent.Reset();
m_shutdown_flag.store(false, std::memory_order_release);
m_thread = std::thread(&VU_Thread::ExecuteRingBuffer, this);
m_thread.Start([this]() { ExecuteRingBuffer(); });
}
void VU_Thread::Close()
{
if (!m_thread.joinable())
if (!m_thread.Joinable())
return;
m_shutdown_flag.store(true, std::memory_order_release);
semaEvent.NotifyOfWork();
m_thread.join();
m_thread.Join();
}
void VU_Thread::Reset()
@ -135,7 +135,6 @@ void VU_Thread::Reset()
void VU_Thread::ExecuteRingBuffer()
{
m_thread_handle = Threading::ThreadHandle::GetForCallingThread();
Threading::SetNameOfCurrentThread("MTVU");
for (;;)
@ -213,7 +212,6 @@ void VU_Thread::ExecuteRingBuffer()
}
}
m_thread_handle = {};
semaEvent.Kill();
}

View File

@ -40,8 +40,7 @@ class VU_Thread final {
Threading::WorkSema semaEvent;
std::atomic_bool m_shutdown_flag{false};
std::thread m_thread;
Threading::ThreadHandle m_thread_handle;
Threading::Thread m_thread;
public:
alignas(16) vifStruct vif;
@ -66,7 +65,7 @@ public:
VU_Thread();
~VU_Thread();
__fi const Threading::ThreadHandle& GetThreadHandle() const { return m_thread_handle; }
__fi const Threading::ThreadHandle& GetThreadHandle() const { return m_thread; }
/// Ensures the VU thread is started.
void Open();