Added basic job system for async

This commit is contained in:
Antoine Pilote
2024-03-10 13:00:34 -04:00
parent f18be64eae
commit ccdb305b54
5 changed files with 108 additions and 4 deletions

25
Nuake/src/Threading/Job.h Normal file
View File

@@ -0,0 +1,25 @@
#pragma once
#include <atomic>
#include <functional>
#include <thread>
namespace Nuake {
class Job
{
public:
Job(std::function<void()> job, std::function<void()> end);
Job(const Job&) = delete;
Job& operator=(const Job&) = delete;
~Job() { m_Thread.join(); }
bool IsDone() { return m_IsDone; }
void End();
private:
std::thread m_Thread;
std::atomic<bool> m_IsDone;
std::function<void()> m_Job;
std::function<void()> m_End;
};
}