From 6db1406d6865278f65b7a3d3e71f6a9a8067d12d Mon Sep 17 00:00:00 2001 From: IlushaShurupov Date: Sun, 23 Jul 2023 10:51:21 +0300 Subject: [PATCH] Graphics module Initial (And some more fixes embedded) --- .github/workflows/cmake.yml | 10 +- .gitmodules | 12 + Allocators/private/HeapAllocatorGlobal.cpp | 76 ++++-- Allocators/public/HeapAllocatorGlobal.hpp | 6 + CMakeLists.txt | 5 + CommandLine/tests/Tests.cpp | 1 - Externals/CMakeLists.txt | 28 +++ Externals/glew | 1 + Externals/glfw | 1 + Externals/imgui | 1 + Externals/nanovg | 1 + Graphics/CMakeLists.txt | 34 +++ Graphics/examples/Example.cpp | 274 +++++++++++++++++++++ Graphics/private/bindings/Window.cpp | 0 Graphics/public/Canvas.hpp | 0 Graphics/public/DebugGui.hpp | 0 Graphics/public/Window.hpp | 8 + Graphics/tests/tests.cpp | 3 + Strings/private/Logging.cpp | 1 - Tokenizer/public/AutomataGraph.h | 3 +- Tokenizer/tests/TestTokenizer.cpp | 1 - Utils/public/Debugging.hpp | 2 +- Utils/public/Multithreading.hpp | 19 ++ 23 files changed, 456 insertions(+), 31 deletions(-) create mode 100644 Externals/CMakeLists.txt create mode 160000 Externals/glew create mode 160000 Externals/glfw create mode 160000 Externals/imgui create mode 160000 Externals/nanovg create mode 100644 Graphics/CMakeLists.txt create mode 100644 Graphics/examples/Example.cpp create mode 100644 Graphics/private/bindings/Window.cpp create mode 100644 Graphics/public/Canvas.hpp create mode 100644 Graphics/public/DebugGui.hpp create mode 100644 Graphics/public/Window.hpp create mode 100644 Graphics/tests/tests.cpp create mode 100644 Utils/public/Multithreading.hpp diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9a2cd92..329bff1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Checkout submodules # checkout rest + - name: Setup externals shell: bash run: | # If your submodules are configured to use SSH instead of HTTPS please uncomment the following line @@ -29,11 +29,15 @@ jobs: git submodule sync --recursive git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 - - name: Install LLVM - run: sudo apt-get install -y llvm + sudo apt-get install python3 python-is-python3 + sudo apt install libx11-dev + + cd Externals/glew/ + make extensions - name: Set LLVM Toolchain run: | + sudo apt-get install -y llvm sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 10 sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 20 diff --git a/.gitmodules b/.gitmodules index 3f056fd..7fd3b15 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,15 @@ [submodule "Externals/asio"] path = Externals/asio url = https://github.com/IlyaShurupov/asio.git +[submodule "Externals/glfw"] + path = Externals/glfw + url = https://github.com/IlyaShurupov/glfw.git +[submodule "Externals/imgui"] + path = Externals/imgui + url = https://github.com/IlyaShurupov/imgui.git +[submodule "Externals/glew"] + path = Externals/glew + url = https://github.com/IlyaShurupov/glew.git +[submodule "Externals/nanovg"] + path = Externals/nanovg + url = https://github.com/IlyaShurupov/nanovg.git diff --git a/Allocators/private/HeapAllocatorGlobal.cpp b/Allocators/private/HeapAllocatorGlobal.cpp index f74cd83..c2ea8a4 100644 --- a/Allocators/private/HeapAllocatorGlobal.cpp +++ b/Allocators/private/HeapAllocatorGlobal.cpp @@ -22,6 +22,8 @@ HeapAllocGlobal::~HeapAllocGlobal() = default; tp::MemHead* tp::HeapAllocGlobal::mEntry = nullptr; tp::ualni tp::HeapAllocGlobal::mNumAllocations = 0; +tp::Mutex tp::HeapAllocGlobal::mMutex; +bool tp::HeapAllocGlobal::mIgnore; // ----------------------- Debug Implementation ---------------------------- // // |----------------| @@ -38,7 +40,8 @@ namespace tp { struct MemHead { MemHead* mPrev; MemHead* mNext; - ualni mBlockSize; + uhalni mBlockSize; + uhalni mIgnored; #ifdef MEM_STACK_TRACE const CallStackCapture::CallStack* mCallStack; #endif @@ -69,12 +72,15 @@ void* HeapAllocGlobal::allocate(ualni aBlockSize) { auto wrap_bottom = data + aBlockSize; if (!head) { return nullptr; } + head->mBlockSize = aBlockSize; + head->mIgnored = mIgnore; // 2) Link with existing blocks + mMutex.lock(); mNumAllocations++; if (mEntry) { - DEBUG_ASSERT(!mEntry->mNext) + DEBUG_ASSERT(mEntry->mNext == nullptr) head->mNext = nullptr; head->mPrev = mEntry; mEntry->mNext = head; @@ -84,15 +90,18 @@ void* HeapAllocGlobal::allocate(ualni aBlockSize) { } mEntry = head; - // 3) Wrap fill - memSetVal(wrap_top, WRAP_SIZE, WRAP_VAL); - memSetVal(wrap_bottom, WRAP_SIZE, WRAP_VAL); - // 4) Trace the stack + // 3) Trace the stack #ifdef MEM_STACK_TRACE head->mCallStack = gCSCapture->getSnapshot(); #endif + mMutex.unlock(); + + // 4) Wrap fill + memSetVal(wrap_top, WRAP_SIZE, WRAP_VAL); + memSetVal(wrap_bottom, WRAP_SIZE, WRAP_VAL); + // 5) clear data #ifdef MEM_CLEAR_ON_ALLOC memSetVal(data, aBlockSize, CLEAR_ALLOC_VAL); @@ -102,6 +111,8 @@ void* HeapAllocGlobal::allocate(ualni aBlockSize) { } void HeapAllocGlobal::deallocate(void* aPtr) { + if (!aPtr) return; + // 1) Restore the pointers auto head = ((MemHead*)((int1*)aPtr - WRAP_SIZE)) - 1; auto wrap_top = (int1*)(head + 1); @@ -109,6 +120,7 @@ void HeapAllocGlobal::deallocate(void* aPtr) { auto wrap_bottom = data + head->mBlockSize; // 2) Unlink with blocks + mMutex.lock(); mNumAllocations--; DEBUG_ASSERT(!mEntry->mNext) if (head->mNext) head->mNext->mPrev = head->mPrev; @@ -116,34 +128,42 @@ void HeapAllocGlobal::deallocate(void* aPtr) { if (head == mEntry) { mEntry = head->mPrev; } + mMutex.unlock(); - // 3) Check the wrap - if (memCompareVal(wrap_top, WRAP_SIZE, WRAP_VAL)) { - CallStackCapture::printSnapshot(head->mCallStack); - ASSERT(!"Allocated Block Wrap Corrupted!") + if (!head->mIgnored) { + // 3) Check the wrap + if (memCompareVal(wrap_top, WRAP_SIZE, WRAP_VAL)) { + CallStackCapture::printSnapshot(head->mCallStack); + ASSERT(!"Allocated Block Wrap Corrupted!") + } + + if (memCompareVal(wrap_bottom, WRAP_SIZE, WRAP_VAL)) { + CallStackCapture::printSnapshot(head->mCallStack); + ASSERT(!"Allocated Block Wrap Corrupted!") + } + + // 4) clear data + #ifdef MEM_CLEAR_ON_ALLOC + memSetVal(data, head->mBlockSize, CLEAR_DEALLOC_VAL); + #endif } - if (memCompareVal(wrap_bottom, WRAP_SIZE, WRAP_VAL)) { - CallStackCapture::printSnapshot(head->mCallStack); - ASSERT(!"Allocated Block Wrap Corrupted!") - } - - // 4) clear data -#ifdef MEM_CLEAR_ON_ALLOC - memSetVal(data, head->mBlockSize, CLEAR_DEALLOC_VAL); -#endif - // 5) free the block free(head); } bool HeapAllocGlobal::checkLeaks() { + ualni ignoredCount = 0; + for (auto iter = mEntry; iter; iter = iter->mPrev) { + ignoredCount += iter->mIgnored; + } + // 1) Check for not deallocated memory - if (mNumAllocations) { + if (mNumAllocations && ignoredCount != mNumAllocations) { #ifdef MEM_STACK_TRACE for (auto iter = mEntry; iter; iter = iter->mPrev) { - CallStackCapture::printSnapshot(iter->mCallStack); + if (!iter->mIgnored) CallStackCapture::printSnapshot(iter->mCallStack); } #endif @@ -153,6 +173,18 @@ bool HeapAllocGlobal::checkLeaks() { return false; } +void HeapAllocGlobal::startIgnore() { + mMutex.lock(); + mIgnore = true; + mMutex.unlock(); +} + +void HeapAllocGlobal::stopIgnore() { + mMutex.lock(); + mIgnore = false; + mMutex.unlock(); +} + HeapAllocGlobal::~HeapAllocGlobal() = default; #endif diff --git a/Allocators/public/HeapAllocatorGlobal.hpp b/Allocators/public/HeapAllocatorGlobal.hpp index 18cae0e..7611531 100644 --- a/Allocators/public/HeapAllocatorGlobal.hpp +++ b/Allocators/public/HeapAllocatorGlobal.hpp @@ -1,6 +1,7 @@ #pragma once #include "Module.hpp" +#include "Multithreading.hpp" namespace tp { @@ -9,6 +10,8 @@ namespace tp { #ifdef MEM_DEBUG static ualni mNumAllocations; static struct MemHead* mEntry; + static Mutex mMutex; + static bool mIgnore; #endif public: @@ -20,6 +23,9 @@ namespace tp { static void deallocate(void* aPtr); static bool checkLeaks(); + static void startIgnore(); + static void stopIgnore(); + public: [[nodiscard]] bool checkWrap() const { return false; } void checkValid() {} diff --git a/CMakeLists.txt b/CMakeLists.txt index db1eb4e..9d883a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,9 @@ add_subdirectory(Allocators) add_subdirectory(Strings) add_subdirectory(Tokenizer) add_subdirectory(CommandLine) + +set(EXTERNALS ../Externals) +add_subdirectory(Externals) + add_subdirectory(Connection) +add_subdirectory(Graphics) diff --git a/CommandLine/tests/Tests.cpp b/CommandLine/tests/Tests.cpp index 89e1d0f..9322365 100644 --- a/CommandLine/tests/Tests.cpp +++ b/CommandLine/tests/Tests.cpp @@ -1,6 +1,5 @@ #include "Tests.hpp" -#include "Testing.hpp" int main() { diff --git a/Externals/CMakeLists.txt b/Externals/CMakeLists.txt new file mode 100644 index 0000000..39c80c3 --- /dev/null +++ b/Externals/CMakeLists.txt @@ -0,0 +1,28 @@ + +add_subdirectory(glew/build/cmake/) +target_compile_definitions(glew_s PUBLIC GLEW_NO_GLU) + +add_subdirectory(glfw) + +project(Imgui) +set(${PROJECT_NAME}_SOURCES + imgui/imgui.cpp + imgui/imgui_draw.cpp + imgui/imgui_tables.cpp + imgui/imgui_widgets.cpp + + imgui/backends/imgui_impl_glfw.cpp + imgui/backends/imgui_impl_opengl3.cpp + ) + +add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_SOURCES}) +include_directories(${PROJECT_NAME} ./glfw/include) +target_include_directories(${PROJECT_NAME} PUBLIC ./imgui/ ./imgui/backends/) + +project(Nanovg) +set(${PROJECT_NAME}_SOURCES + nanovg/src/nanovg.c + ) + +add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_SOURCES}) +target_include_directories(${PROJECT_NAME} PUBLIC ./nanovg/src/ ./nanovg/obsolete/) diff --git a/Externals/glew b/Externals/glew new file mode 160000 index 0000000..a98195b --- /dev/null +++ b/Externals/glew @@ -0,0 +1 @@ +Subproject commit a98195b83df746202bdf5a6f92e9d4e86b497045 diff --git a/Externals/glfw b/Externals/glfw new file mode 160000 index 0000000..3eaf125 --- /dev/null +++ b/Externals/glfw @@ -0,0 +1 @@ +Subproject commit 3eaf1255b29fdf5c2895856c7be7d7185ef2b241 diff --git a/Externals/imgui b/Externals/imgui new file mode 160000 index 0000000..1109de3 --- /dev/null +++ b/Externals/imgui @@ -0,0 +1 @@ +Subproject commit 1109de38277fd2d14d4dca4c1cb8d4a2c4ff0f95 diff --git a/Externals/nanovg b/Externals/nanovg new file mode 160000 index 0000000..7544c11 --- /dev/null +++ b/Externals/nanovg @@ -0,0 +1 @@ +Subproject commit 7544c114e83db7cf67bd1c9e012349b70caacc2f diff --git a/Graphics/CMakeLists.txt b/Graphics/CMakeLists.txt new file mode 100644 index 0000000..5c7f33e --- /dev/null +++ b/Graphics/CMakeLists.txt @@ -0,0 +1,34 @@ + +cmake_minimum_required(VERSION 3.2) + +set(CMAKE_CXX_STANDARD 23) + +project(Graphics) + +### ---------------------- Externals --------------------- ### +set(BINDINGS_INCLUDE ${EXTERNALS}/glfw/include ${EXTERNALS}/glew/include) +set(BINDINGS_LIBS glfw glew_s Imgui Nanovg) + + +### ---------------------- Static Library --------------------- ### +file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp") +file(GLOB HEADERS "./public/*.hpp") +add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) +target_include_directories(${PROJECT_NAME} PUBLIC ./public/) +target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE}) +target_link_libraries(${PROJECT_NAME} PUBLIC Strings) +target_link_libraries(${PROJECT_NAME} PRIVATE ${BINDINGS_LIBS}) + +### -------------------------- Examples -------------------------- ### +add_executable(${PROJECT_NAME}Example ./examples/Example.cpp) +target_link_libraries(${PROJECT_NAME}Example ${PROJECT_NAME} ${BINDINGS_LIBS}) +target_include_directories(${PROJECT_NAME}Example PRIVATE ${BINDINGS_INCLUDE}) + +### -------------------------- Tests -------------------------- ### +enable_testing() +file(GLOB TEST_SOURCES "./tests/*.cpp") +add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) +target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} Utils) +add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) + +install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib) \ No newline at end of file diff --git a/Graphics/examples/Example.cpp b/Graphics/examples/Example.cpp new file mode 100644 index 0000000..6b0802d --- /dev/null +++ b/Graphics/examples/Example.cpp @@ -0,0 +1,274 @@ +#include "Allocators.hpp" + +// -------- OpenGL -------- // +#include + +// -------- Window Context -------- // +#include + +// -------- Debug UI -------- // +#include +#include +#include + +// -------- Canvas -------- // +#define NANOVG_GL3_IMPLEMENTATION +//#include +//#include + +#include + +class Showoff { + class GL { + // Showoff data + GLuint vao{}; + GLuint vbo{}; + GLfloat vertices[9] = { + -0.5f, -0.5f, 0.0f, // Left vertex + 0.5f, -0.5f, 0.0f, // Right vertex + 0.0f, 0.5f, 0.0f // Top vertex + }; + + public: + GL() = default; + + void init() { + // Create a Vertex Array Object (VAO) + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + // Create a Vertex Buffer Object (VBO) + glGenBuffers(1, &vbo); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + + // Set up vertex attributes + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (void*) nullptr); + glEnableVertexAttribArray(0); + } + + void deinit() { + glDeleteBuffers(1, &vbo); + glDeleteVertexArrays(1, &vao); + } + + static void beginDraw() { + glClear(GL_COLOR_BUFFER_BIT); + glDrawArrays(GL_TRIANGLES, 0, 3); + } + + static void endDraw() { + } + }; + + class GUI { + ImGuiIO* io{}; + ImGuiContext* ctx{}; + public: + GUI() = default; + + void init(GLFWwindow* window) { + IMGUI_CHECKVERSION(); + ctx = ImGui::CreateContext(); + io = &ImGui::GetIO(); + + // Initialize ImGui with GLFW and OpenGL + ImGui_ImplGlfw_InitForOpenGL(window, true); + ImGui_ImplOpenGL3_Init("#version 330"); + } + + void deinit() { + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplGlfw_Shutdown(); + ImGui::DestroyContext(); + } + + void beginDraw() { + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); + + // ImGui code goes here + ImGui::Begin("Window"); + ImGui::End(); + } + + void endDraw() { + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + } + }; + + /* + class Canvas { + + NVGcontext* vg; + float width; + float height; + + public: + Canvas() = default; + + void init(int aWidth, int aHeight) { + width = aWidth; + height = aHeight; + + vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES); + } + + void deinit() { + // Cleanup + nvgDeleteGL3(vg); + } + + void beginDraw() { + // Start NanoVG rendering + nvgBeginFrame(vg, width, height, 1.0); + + // Clear the screen + nvgBeginPath(vg); + nvgRect(vg, 0, 0, width, height); + nvgFillColor(vg, nvgRGBf(0.2f, 0.2f, 0.2f)); + nvgFill(vg); + + // Draw a rectangle + nvgBeginPath(vg); + nvgRect(vg, 200, 200, 300, 200); + nvgFillColor(vg, nvgRGBf(0.8f, 0.4f, 0.1f)); + nvgFill(vg); + + // End NanoVG rendering + nvgEndFrame(vg); + } + + void endDraw() { + // End NanoVG rendering + nvgEndFrame(vg); + } + }; + */ + +public: + Showoff() = default; + + void init(GLFWwindow* window, int aWidth, int aHeight) { + gui.init(window); + gl.init(); + // canvas.init(aWidth, aHeight); + } + + void deinit() { + gui.deinit(); + gl.deinit(); + // canvas.deinit(); + } + + void draw() { + gl.beginDraw(); + // canvas.beginDraw(); + gui.beginDraw(); + gui.endDraw(); + // canvas.endDraw(); + gl.endDraw(); + } + +private: + GUI gui{}; + GL gl{}; + // Canvas canvas{}; +}; + +class Window { + Window(int width, int height, const char* title) { + // Create a window and OpenGL context + window = glfwCreateWindow(width, height, title, nullptr, nullptr); + if (!window) { + printf("Failed to create GLFW window\n"); + return; + } + + glfwMakeContextCurrent(window); + + // Initialize GLEW + if (glewInit() != GLEW_OK) { + printf("Failed to initialize GLEW\n"); + return; + } + + showoff.init(window, width, height); + } + + ~Window() { + showoff.deinit(); + glfwDestroyWindow(window); + } + +public: + + static Window* createWindow(int width, int height, const char* title) { + static int count = 1; + if (!count) { + printf("Window class is a singleton\n"); + return nullptr; + } + count--; + + // Initialize GLFW + if (!glfwInit()) { + printf("Failed to initialize GLFW\n"); + return nullptr; + } + + // Set the GLFW error callback + glfwSetErrorCallback([] (int error, const char* description) { + printf("GLFW Error: %i %s\n", error, description); + }); + + return new Window(width, height, title); + } + + static void destroyWindow(Window* window) { + delete window; + glfwTerminate(); + } + +public: + void renderLoop() { + while (!glfwWindowShouldClose(window)) { + + showoff.draw(); + + // Swap buffers and poll events + glfwSwapBuffers(window); + glfwPollEvents(); + } + } + +private: + GLFWwindow* window; + Showoff showoff; +}; + + +int main() { + tp::ModuleManifest* deps[] = { &tp::gModuleAllocators, nullptr }; + tp::ModuleManifest testModule("Example", nullptr, nullptr, deps); + + if (!testModule.initialize()) { + return 1; + } + + { + //tp::HeapAllocGlobal::startIgnore(); + auto window = Window::createWindow(800, 600, "Window 1"); + //tp::HeapAllocGlobal::stopIgnore(); + + if (window) { + window->renderLoop(); + } + + Window::destroyWindow(window); + } + + testModule.deinitialize(); +} diff --git a/Graphics/private/bindings/Window.cpp b/Graphics/private/bindings/Window.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Graphics/public/Canvas.hpp b/Graphics/public/Canvas.hpp new file mode 100644 index 0000000..e69de29 diff --git a/Graphics/public/DebugGui.hpp b/Graphics/public/DebugGui.hpp new file mode 100644 index 0000000..e69de29 diff --git a/Graphics/public/Window.hpp b/Graphics/public/Window.hpp new file mode 100644 index 0000000..2645460 --- /dev/null +++ b/Graphics/public/Window.hpp @@ -0,0 +1,8 @@ +// +// Created by ilusha on 22.07.23. +// + +#ifndef TYPES_WINDOW_HPP +#define TYPES_WINDOW_HPP + +#endif//TYPES_WINDOW_HPP diff --git a/Graphics/tests/tests.cpp b/Graphics/tests/tests.cpp new file mode 100644 index 0000000..560e551 --- /dev/null +++ b/Graphics/tests/tests.cpp @@ -0,0 +1,3 @@ + int main() { + + } \ No newline at end of file diff --git a/Strings/private/Logging.cpp b/Strings/private/Logging.cpp index 17c3c21..f55f22b 100644 --- a/Strings/private/Logging.cpp +++ b/Strings/private/Logging.cpp @@ -1,6 +1,5 @@ #include "Logging.hpp" -#include "Allocators.hpp" #include diff --git a/Tokenizer/public/AutomataGraph.h b/Tokenizer/public/AutomataGraph.h index 23c4aec..3913535 100644 --- a/Tokenizer/public/AutomataGraph.h +++ b/Tokenizer/public/AutomataGraph.h @@ -222,7 +222,6 @@ namespace tp { // all NFA states that are reachable from initial DFA State for specific symbol in alphabet struct DState { - struct DTransition { DState* state = nullptr; tAlphabetType accepting_code; @@ -231,7 +230,7 @@ namespace tp { List nStates; List transitions; - Vertex* dVertex = nullptr; // relevant DFA vertex + Vertex* dVertex= nullptr; // relevant DFA vertex #ifdef ENV_BUILD_DEBUG ualni debug_idx = 0; diff --git a/Tokenizer/tests/TestTokenizer.cpp b/Tokenizer/tests/TestTokenizer.cpp index d6b40a1..4fd38ae 100644 --- a/Tokenizer/tests/TestTokenizer.cpp +++ b/Tokenizer/tests/TestTokenizer.cpp @@ -1,4 +1,3 @@ - #include "Testing.hpp" #include "Tokenizer.hpp" #include diff --git a/Utils/public/Debugging.hpp b/Utils/public/Debugging.hpp index 1378c58..5444ae6 100644 --- a/Utils/public/Debugging.hpp +++ b/Utils/public/Debugging.hpp @@ -3,7 +3,7 @@ #include "Environment.hpp" #include "Map.hpp" -#define MAX_CALL_DEPTH_CAPTURE 16 +#define MAX_CALL_DEPTH_CAPTURE 128 #define MAX_CALL_CAPTURES_MEM_SIZE_MB 16 #define MAX_DEBUG_INFO_LEN 63 #define FRAMES_TO_SKIP_START 2 diff --git a/Utils/public/Multithreading.hpp b/Utils/public/Multithreading.hpp new file mode 100644 index 0000000..779914d --- /dev/null +++ b/Utils/public/Multithreading.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace tp { + class Mutex { + pthread_mutex_t mMutex {}; + public: + Mutex() = default; + + void lock() { + pthread_mutex_lock(&mMutex); + } + + void unlock() { + pthread_mutex_unlock(&mMutex); + } + }; +} \ No newline at end of file