main: threads sleep if paused

This commit is contained in:
2026-03-18 10:47:11 +00:00
parent b68f9b2e6e
commit a69b14bf4d

View File

@@ -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);
}