VU: port BaseVUmicroCPU to std::atomic

This commit is contained in:
Gregory Hainaut 2016-02-22 21:58:13 +01:00
parent 8555a87380
commit 40b1a3996a
2 changed files with 6 additions and 6 deletions

View File

@ -49,7 +49,7 @@ class BaseCpuProvider
protected:
// allocation counter for multiple calls to Reserve. Most implementations should utilize
// this variable for sake of robustness.
u32 m_Reserved;
std::atomic<int> m_Reserved;
public:
// this boolean indicates to some generic logging facilities if the VU's registers
@ -68,7 +68,7 @@ public:
{
try {
if( m_Reserved != 0 )
Console.Warning( "Cleanup miscount detected on CPU provider. Count=%d", m_Reserved );
Console.Warning( "Cleanup miscount detected on CPU provider. Count=%d", m_Reserved.load() );
}
DESTRUCTOR_CATCHALL
}

View File

@ -297,22 +297,22 @@ void recMicroVU0::Vsync() throw() { mVUvsyncUpdate(microVU0); }
void recMicroVU1::Vsync() throw() { mVUvsyncUpdate(microVU1); }
void recMicroVU0::Reserve() {
if (AtomicExchange(m_Reserved, 1) == 0)
if (m_Reserved.exchange(1) == 0)
mVUinit(microVU0, 0);
}
void recMicroVU1::Reserve() {
if (AtomicExchange(m_Reserved, 1) == 0) {
if (m_Reserved.exchange(1) == 0) {
mVUinit(microVU1, 1);
vu1Thread.Start();
}
}
void recMicroVU0::Shutdown() throw() {
if (AtomicExchange(m_Reserved, 0) == 1)
if (m_Reserved.exchange(0) == 1)
mVUclose(microVU0);
}
void recMicroVU1::Shutdown() throw() {
if (AtomicExchange(m_Reserved, 0) == 1) {
if (m_Reserved.exchange(0) == 1) {
vu1Thread.WaitVU();
mVUclose(microVU1);
}