Add function to check if sleeping
This commit is contained in:
@@ -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; }
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user