make the scoping thing clearer

This commit is contained in:
drath
2025-10-01 22:59:39 +02:00
parent 9a769aec27
commit aa75aa2b30

View File

@@ -41,7 +41,7 @@ struct Sensors {
std::mutex mtx; // making sure the struct isnt accessed by multiple threads at once
};
void sighandler(int s) {
void sighandler(int s) { // can i remove int s
std::println("[Signal] got SIGINT/SIGTERM, exiting...");
sem::main.release();
sem::display.release();
@@ -147,8 +147,8 @@ int main(int argc, char* argv[]) {
/* what the fucking kind of code is this
this code below spins up display/sensors/homeassistant functions as threads and halts until sem::main is released in sighandler
its scoped because when sem::main is released, program destroys the std::jthreads and the vector before leaving the scope
this causes all threads to join back into main thread before leaving the scope, so we can safely destroy pSensors without segfault
then the program leaves the scope, but before that, it destroys the std::jthreads in the "threads" vector
this causes all threads to gracefully close and join back into main thread, so we can safely destroy pSensors without segfault
*/
{