/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#pragma once

#include <condition_variable>
#include <mutex>
#include <string_view>

namespace OpenVulkano
{
	class IEventHandler;

	class ThreadBackgroundSleep final
	{
		std::mutex m_mutex;
		std::condition_variable m_condVar;
		bool m_inBackground = false;
		IEventHandler* m_resignHandler = nullptr;
		IEventHandler* m_resumeHandler = nullptr;

	public:
		static ThreadBackgroundSleep INSTANCE;

		ThreadBackgroundSleep();

		~ThreadBackgroundSleep();

		void Resume();

		void CheckForBackground(std::string_view taskName);
	};
}
