slow down race condition, kinda ugly
This commit is contained in:
6
main.cpp
6
main.cpp
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user