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

View File

@@ -53,6 +53,7 @@
#include <src/Resource/StaticResources.h>
#include <src/Scripting/ScriptingEngineNet.h>
#include <src/Threading/JobSystem.h>
namespace Nuake {
@@ -127,10 +128,14 @@ namespace Nuake {
{
if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5)))
{
SceneSnapshot = Engine::GetCurrentScene()->Copy();
this->SceneSnapshot = Engine::GetCurrentScene()->Copy();
ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
Engine::EnterPlayMode();
auto job = [this]()
{
ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
};
JobSystem::Get().Dispatch(job, []() { Engine::EnterPlayMode(); });
}
if (ImGui::BeginItemTooltip())
@@ -240,7 +245,12 @@ namespace Nuake {
if (ImGui::Button(ICON_FA_HAMMER, ImVec2(30, 30)))
{
Nuake::ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
JobSystem::Get().Dispatch([]()
{
Nuake::ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
},
[]() {}
);
}
if (ImGui::BeginItemTooltip())