From a69b14bf4d5ad35d8e38d482b63007e16b93daa5 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 18 Mar 2026 10:47:11 +0000 Subject: [PATCH] main: threads sleep if paused --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.c b/src/main.c index 0f192eb..96d0e93 100644 --- a/src/main.c +++ b/src/main.c @@ -31,6 +31,7 @@ struct ThreadState bool paused, done; }; +static const struct timespec THREAD_SLEEP = {.tv_nsec = 5000}; int thread_simulation_iterate(void *ptr) { struct ThreadState *state = ptr; @@ -38,6 +39,7 @@ int thread_simulation_iterate(void *ptr) { while (state->paused && !state->done) { + thrd_sleep(&THREAD_SLEEP, NULL); } simulation_iterate(state->simulation); } @@ -51,6 +53,7 @@ int thread_simulation_mutate(void *ptr) { while (state->paused && !state->done) { + thrd_sleep(&THREAD_SLEEP, NULL); } simulation_mutate(state->simulation); }