Add function to check if sleeping

This commit is contained in:
Georg Hagen
2024-12-12 18:16:44 +01:00
parent 2a7cf31471
commit 955bf6570d

View File

@@ -6,6 +6,7 @@
#pragma once
#include <atomic>
#include <condition_variable>
#include <mutex>
@@ -15,7 +16,8 @@ namespace OpenVulkano
{
std::mutex m_mutex;
std::condition_variable m_condVar;
bool m_paused = false;
std::atomic_bool m_paused = false;
std::atomic_bool m_isSleeping = false;
public:
void Pause() { m_paused = true; }
@@ -33,9 +35,13 @@ namespace OpenVulkano
{
while (m_paused)
{
m_isSleeping = true;
std::unique_lock l(m_mutex);
m_condVar.wait(l, [this]{ return !m_paused; });
}
m_isSleeping = false;
}
bool IsSleeping() const { return m_isSleeping; }
};
}