From 1a9d905a3b4466a7d4f4f8da15aad1d905c4bdd6 Mon Sep 17 00:00:00 2001 From: Malcolm Vigren Date: Thu, 28 Mar 2024 17:07:41 +0100 Subject: [PATCH] Remove multithreading from simulator --- compile_commands.json | 17 +++++++++++++++++ simulator/simulator.cpp | 27 ++++----------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/compile_commands.json b/compile_commands.json index c13ac56..b1adc35 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -6499,5 +6499,22 @@ "directory": "/home/malcolm/Programming/ZeKeyboard/firmware", "file": "/home/malcolm/.arduino15/packages/teensy/hardware/avr/1.58.1/cores/teensy4/usb_touch.c", "output": "/home/malcolm/Programming/ZeKeyboard/firmware/build/core/home/malcolm/.arduino15/packages/teensy/hardware/avr/1.58.1/cores/teensy4/usb_touch.c.o" + }, + { + "arguments": [ + "/usr/bin/g++", + "-c", + "-g", + "-Wall", + "-Wextra", + "-std=gnu++23", + "-I/usr/include/SFML", + "-o", + "obj/simulator.o", + "simulator.cpp" + ], + "directory": "/home/malcolm/Programming/ZeKeyboard/firmware/simulator", + "file": "/home/malcolm/Programming/ZeKeyboard/firmware/simulator/simulator.cpp", + "output": "/home/malcolm/Programming/ZeKeyboard/firmware/simulator/obj/simulator.o" } ] diff --git a/simulator/simulator.cpp b/simulator/simulator.cpp index c02b311..96be5e5 100644 --- a/simulator/simulator.cpp +++ b/simulator/simulator.cpp @@ -1,37 +1,18 @@ #include "simulator_device.h" #include "../core/firmware.h" #include "simulator_window.h" -#include -void window_thread(simulator::SimulatorWindow& window) +int main() { + simulator::SimulatorDevice device; + core::Firmware firmware{device}; + simulator::SimulatorWindow window{device, firmware}; while (window.is_open()) { window.update(); - } -} - - -void firmware_thread(core::Firmware& firmware) -{ - while (true) - { firmware.update(); } -} - - -int main() -{ - simulator::SimulatorDevice device; - core::Firmware firmware{device}; - simulator::SimulatorWindow window{device, firmware}; - - std::thread window_thread{::window_thread, std::ref(window)}; - std::thread firmware_thread{::firmware_thread, std::ref(firmware)}; - window_thread.join(); - firmware_thread.join(); return 0; }