From 955bf6570d44427171ce03e16176dd036d6ac91d Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Thu, 12 Dec 2024 18:16:44 +0100 Subject: [PATCH] Add function to check if sleeping --- openVulkanoCpp/Base/PauseCV.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openVulkanoCpp/Base/PauseCV.hpp b/openVulkanoCpp/Base/PauseCV.hpp index 1d23247..2df1791 100644 --- a/openVulkanoCpp/Base/PauseCV.hpp +++ b/openVulkanoCpp/Base/PauseCV.hpp @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -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; } }; }