summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2016-08-05 16:04:39 +0200
committerLéo Lam <leo@innovatetechnologi.es>2016-08-10 16:08:15 +0200
commitdca22e08eb96a401406ef7fa62c59eea1b837f7b (patch)
tree5b404c3f0f13cb0cd716f9e311089e7989d8d8de /Source/Core/VideoCommon
parentc6a0e543a520204c1e56033ffa2511252b0dda4a (diff)
Use Common::Flag and Common::Event when possible
Replaces old and simple usages of std::atomic<bool> with Common::Flag (which was introduced after the initial usage), so it's clear that the variable is a flag and because Common::Flag is well tested. This also replaces the ready logic in WiimoteReal with Common::Event since it was basically just unnecessarily reimplementing Common::Event.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/AsyncRequests.cpp4
-rw-r--r--Source/Core/VideoCommon/AsyncRequests.h6
-rw-r--r--Source/Core/VideoCommon/CommandProcessor.cpp25
-rw-r--r--Source/Core/VideoCommon/Fifo.cpp8
4 files changed, 22 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp
index 32f407373b..d88bb7aa50 100644
--- a/Source/Core/VideoCommon/AsyncRequests.cpp
+++ b/Source/Core/VideoCommon/AsyncRequests.cpp
@@ -19,7 +19,7 @@ AsyncRequests::AsyncRequests() : m_enable(false), m_passthrough(true)
void AsyncRequests::PullEventsInternal()
{
std::unique_lock<std::mutex> lock(m_mutex);
- m_empty.store(true);
+ m_empty.Set();
while (!m_queue.empty())
{
@@ -76,7 +76,7 @@ void AsyncRequests::PushEvent(const AsyncRequests::Event& event, bool blocking)
return;
}
- m_empty.store(false);
+ m_empty.Clear();
m_wake_me_up_again |= blocking;
if (!m_enable)
diff --git a/Source/Core/VideoCommon/AsyncRequests.h b/Source/Core/VideoCommon/AsyncRequests.h
index bcf9c1ce7e..f5ece7828f 100644
--- a/Source/Core/VideoCommon/AsyncRequests.h
+++ b/Source/Core/VideoCommon/AsyncRequests.h
@@ -4,13 +4,13 @@
#pragma once
-#include <atomic>
#include <condition_variable>
#include <mutex>
#include <queue>
#include <vector>
#include "Common/CommonTypes.h"
+#include "Common/Flag.h"
struct EfbPokeData;
@@ -70,7 +70,7 @@ public:
void PullEvents()
{
- if (!m_empty.load())
+ if (!m_empty.IsSet())
PullEventsInternal();
}
void PushEvent(const Event& event, bool blocking = false);
@@ -84,7 +84,7 @@ private:
static AsyncRequests s_singleton;
- std::atomic<bool> m_empty;
+ Common::Flag m_empty;
std::queue<Event> m_queue;
std::mutex m_mutex;
std::condition_variable m_cond;
diff --git a/Source/Core/VideoCommon/CommandProcessor.cpp b/Source/Core/VideoCommon/CommandProcessor.cpp
index 6e841d5fca..2b82173110 100644
--- a/Source/Core/VideoCommon/CommandProcessor.cpp
+++ b/Source/Core/VideoCommon/CommandProcessor.cpp
@@ -9,6 +9,7 @@
#include "Common/Atomic.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
+#include "Common/Flag.h"
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/CoreTiming.h"
@@ -36,8 +37,8 @@ static u16 m_bboxright;
static u16 m_bboxbottom;
static u16 m_tokenReg;
-static std::atomic<bool> s_interrupt_set;
-static std::atomic<bool> s_interrupt_waiting;
+static Common::Flag s_interrupt_set;
+static Common::Flag s_interrupt_waiting;
static bool IsOnThread()
{
@@ -106,8 +107,8 @@ void Init()
fifo.bFF_LoWatermark = 0;
fifo.bFF_LoWatermarkInt = 0;
- s_interrupt_set.store(false);
- s_interrupt_waiting.store(false);
+ s_interrupt_set.Clear();
+ s_interrupt_waiting.Clear();
et_UpdateInterrupts = CoreTiming::RegisterEvent("CPInterrupt", UpdateInterrupts_Wrapper);
}
@@ -324,18 +325,18 @@ void UpdateInterrupts(u64 userdata)
{
if (userdata)
{
- s_interrupt_set.store(true);
+ s_interrupt_set.Set();
INFO_LOG(COMMANDPROCESSOR, "Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true);
}
else
{
- s_interrupt_set.store(false);
+ s_interrupt_set.Clear();
INFO_LOG(COMMANDPROCESSOR, "Interrupt cleared");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, false);
}
CoreTiming::ForceExceptionCheck(0);
- s_interrupt_waiting.store(false);
+ s_interrupt_waiting.Clear();
Fifo::RunGpu();
}
@@ -347,7 +348,7 @@ void UpdateInterruptsFromVideoBackend(u64 userdata)
bool IsInterruptWaiting()
{
- return s_interrupt_waiting.load();
+ return s_interrupt_waiting.IsSet();
}
void SetCPStatusFromGPU()
@@ -387,7 +388,7 @@ void SetCPStatusFromGPU()
bool interrupt = (bpInt || ovfInt || undfInt) && m_CPCtrlReg.GPReadEnable;
- if (interrupt != s_interrupt_set.load() && !s_interrupt_waiting.load())
+ if (interrupt != s_interrupt_set.IsSet() && !s_interrupt_waiting.IsSet())
{
u64 userdata = interrupt ? 1 : 0;
if (IsOnThread())
@@ -395,7 +396,7 @@ void SetCPStatusFromGPU()
if (!interrupt || bpInt || undfInt || ovfInt)
{
// Schedule the interrupt asynchronously
- s_interrupt_waiting.store(true);
+ s_interrupt_waiting.Set();
CommandProcessor::UpdateInterruptsFromVideoBackend(userdata);
}
}
@@ -418,14 +419,14 @@ void SetCPStatusFromCPU()
bool interrupt = (bpInt || ovfInt || undfInt) && m_CPCtrlReg.GPReadEnable;
- if (interrupt != s_interrupt_set.load() && !s_interrupt_waiting.load())
+ if (interrupt != s_interrupt_set.IsSet() && !s_interrupt_waiting.IsSet())
{
u64 userdata = interrupt ? 1 : 0;
if (IsOnThread())
{
if (!interrupt || bpInt || undfInt || ovfInt)
{
- s_interrupt_set.store(interrupt);
+ s_interrupt_set.Set(interrupt);
INFO_LOG(COMMANDPROCESSOR, "Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt);
}
diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp
index 504a274157..8d3df111e4 100644
--- a/Source/Core/VideoCommon/Fifo.cpp
+++ b/Source/Core/VideoCommon/Fifo.cpp
@@ -36,7 +36,7 @@ static bool s_skip_current_frame = false;
static Common::BlockingLoop s_gpu_mainloop;
-static std::atomic<bool> s_emu_running_state;
+static Common::Flag s_emu_running_state;
// Most of this array is unlikely to be faulted in...
static u8 s_fifo_aux_data[FIFO_SIZE];
@@ -147,13 +147,13 @@ void ExitGpuLoop()
FlushGpu();
// Terminate GPU thread loop
- s_emu_running_state.store(true);
+ s_emu_running_state.Set();
s_gpu_mainloop.Stop(false);
}
void EmulatorState(bool running)
{
- s_emu_running_state.store(running);
+ s_emu_running_state.Set(running);
if (running)
s_gpu_mainloop.Wakeup();
else
@@ -307,7 +307,7 @@ void RunGpuLoop()
g_video_backend->PeekMessages();
// Do nothing while paused
- if (!s_emu_running_state.load())
+ if (!s_emu_running_state.IsSet())
return;
if (s_use_deterministic_gpu_thread)