mirror of https://github.com/PCSX2/pcsx2.git
MTVU: Use Thread wrapper
This commit is contained in:
parent
457ec7f6f5
commit
bb9a551318
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue