slow down race condition, kinda ugly

This commit is contained in:
2025-12-28 13:55:58 +01:00
parent fb9bf7d29c
commit 12d7ab9b0f

View File

@@ -172,10 +172,12 @@ int main() {
{
std::unique_ptr<Sensors> pSensors = std::make_unique<Sensors>();
std::vector<std::jthread> threads;
std::function<void(std::stop_token st, Sensors * s)> funcs[] = {displayThread, hassThread, sensorsThread};
std::function<void(std::stop_token st, Sensors * s)> funcs[] = {displayThread, sensorsThread, hassThread};
for (auto& f : funcs)
for (auto& f : funcs) {
threads.emplace_back(f, pSensors.get()); // params: function, stop_token (implied), pointer to sensor struct
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // start threads with delay so displayThread can quit the app if theres no lcd
}
sem::main.acquire();
}