From d8a4a25186e59316a5c9705052750f3ece6eb067 Mon Sep 17 00:00:00 2001
From: emufan4568 <geoster3d@gmail.com>
Date: Tue, 16 Nov 2021 19:41:07 +0200
Subject: [PATCH] Move ComponentManger to a seperate thread

* Currently the interperter performance was extermely slow
due to the handling of window events from glfw blocking the execution
of new instructions. Moving the execution to a seperate thread, results
in massive performance improvements. However the current implementation
is only temporary and will be modularized in the future.
---
 src/main.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index e386021..f08ed04 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,7 @@
 #include <glad/glad.h>
 #include <GLFW/glfw3.h>
 #include <common/manager.hpp>
+#include <thread>
 
 int main()
 {
@@ -25,16 +26,15 @@ int main()
     if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
         return -1;
 
+    /* Move ComponentManger to its own thread for maximum performance. */
     ComponentManager manager;
+    std::thread thread([&]() { while (true) { manager.tick(); } });
 
     while (!glfwWindowShouldClose(window))
     {
 		if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
         	glfwSetWindowShouldClose(window, true);
 
-        /* Update all the components (CPU, GPU, DMA) */
-        manager.tick();
-
         glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
         glClear(GL_COLOR_BUFFER_BIT);
 
-- 
GitLab