Common: Convert BlockingLoop::StopMode to enum class

This commit is contained in:
Dentomologist 2023-06-04 20:25:20 -07:00
parent c8559a7933
commit 3c80f821c0
2 changed files with 10 additions and 10 deletions

View File

@ -21,15 +21,15 @@ namespace Common
class BlockingLoop class BlockingLoop
{ {
public: public:
enum StopMode enum class StopMode
{ {
kNonBlock, NonBlock,
kBlock, Block,
kBlockAndGiveUp, BlockAndGiveUp,
}; };
BlockingLoop() { m_stopped.Set(); } BlockingLoop() { m_stopped.Set(); }
~BlockingLoop() { Stop(kBlockAndGiveUp); } ~BlockingLoop() { Stop(StopMode::BlockAndGiveUp); }
// Triggers to rerun the payload of the Run() function at least once again. // Triggers to rerun the payload of the Run() function at least once again.
// This function will never block and is designed to finish as fast as possible. // This function will never block and is designed to finish as fast as possible.
void Wakeup() void Wakeup()
@ -200,7 +200,7 @@ public:
// Quits the main loop. // Quits the main loop.
// By default, it will wait until the main loop quits. // By default, it will wait until the main loop quits.
// Be careful to not use the blocking way within the payload of the Run() method. // Be careful to not use the blocking way within the payload of the Run() method.
void Stop(StopMode mode = kBlock) void Stop(StopMode mode = StopMode::Block)
{ {
if (m_stopped.IsSet()) if (m_stopped.IsSet())
return; return;
@ -212,12 +212,12 @@ public:
switch (mode) switch (mode)
{ {
case kNonBlock: case StopMode::NonBlock:
break; break;
case kBlock: case StopMode::Block:
Wait(); Wait();
break; break;
case kBlockAndGiveUp: case StopMode::BlockAndGiveUp:
WaitYield(std::chrono::milliseconds(100), [&] { WaitYield(std::chrono::milliseconds(100), [&] {
// If timed out, assume no one will come along to call Run, so force a break // If timed out, assume no one will come along to call Run, so force a break
m_stopped.Set(); m_stopped.Set();

View File

@ -131,7 +131,7 @@ void FifoManager::ExitGpuLoop(Core::System& system)
// Terminate GPU thread loop // Terminate GPU thread loop
m_emu_running_state.Set(); m_emu_running_state.Set();
m_gpu_mainloop.Stop(m_gpu_mainloop.kNonBlock); m_gpu_mainloop.Stop(Common::BlockingLoop::StopMode::NonBlock);
} }
void FifoManager::EmulatorState(bool running) void FifoManager::EmulatorState(bool running)