cellAdecClose, cellVdecClose fix

This commit is contained in:
Nekotekina 2014-10-18 02:20:03 +04:00
parent 18930a43f2
commit 318d06efda
8 changed files with 401 additions and 392 deletions

View file

@ -1,6 +1,6 @@
#pragma once
#include "Utilities/SMutex.h"
static const volatile bool sq_no_wait = true;
template<typename T, u32 SQSize = 666>
class SQueue
@ -22,13 +22,13 @@ public:
return SQSize;
}
bool Push(const T& data)
bool Push(const T& data, const volatile bool* do_exit)
{
while (true)
{
if (m_count >= SQSize)
{
if (Emu.IsStopped())
if (Emu.IsStopped() || do_exit && *do_exit)
{
return false;
}
@ -49,13 +49,13 @@ public:
}
}
bool Pop(T& data)
bool Pop(T& data, const volatile bool* do_exit)
{
while (true)
{
if (!m_count)
{
if (Emu.IsStopped())
if (Emu.IsStopped() || do_exit && *do_exit)
{
return false;
}
@ -101,13 +101,13 @@ public:
m_count = 0;
}
T& Peek(u32 pos = 0)
T& Peek(const volatile bool* do_exit, u32 pos = 0)
{
while (true)
{
if (m_count <= pos)
{
if (Emu.IsStopped())
if (Emu.IsStopped() || do_exit && *do_exit)
{
break;
}
@ -126,19 +126,4 @@ public:
}
return m_data[(m_pos + pos) % SQSize];
}
T& PeekIfExist(u32 pos = 0)
{
static T def_value;
std::lock_guard<std::mutex> lock(m_mutex);
if (m_count <= pos)
{
return def_value;
}
else
{
return m_data[(m_pos + pos) % SQSize];
}
}
};