From 74e645634344d05bb7f2c81d42c03ec5d2ff5774 Mon Sep 17 00:00:00 2001 From: Sara Gerretsen Date: Tue, 23 Sep 2025 14:24:47 +0200 Subject: [PATCH] chore: some comments on variables in simulation.cpp --- src/simulation.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index 832af83..f581901 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -20,22 +20,27 @@ #define SIM_MULTITHREADING 1 namespace simulation { -bool drawDebugInfo{ true }; - +// Encapsulates the data relevant to a GoL rule's workload struct ThreadWorkload { size_t seg_idx{0}, seg_len{1}; std::mutex mtx{}; std::vector changes{}; }; -static std::set living{}; +bool drawDebugInfo{ true }; // draw next step's changes over current state +static std::set living{}; // The set of currently alive cells + +// Ruleset workload abstraction static std::vector> overpopulated{}; static std::vector> underpopulated{}; static std::vector> born{}; -static uint64_t generationStartTime{ 0 }; -static unsigned tasks{ 0 }; std::mutex tasksMutex{}; +// Multithreading +static unsigned tasks{ 0 }; +static std::mutex tasksMutex{}; static std::condition_variable tasksChanged{}; +// ns timestamp of the start of the last generation change calculation +static uint64_t generationStartTime{ 0 }; CellIterator::CellIterator(Cell begin, Cell end) : state{ begin } , begin{ begin }, end{ end } {}