main: threads sleep if paused
This commit is contained in:
@@ -31,6 +31,7 @@ struct ThreadState
|
|||||||
bool paused, done;
|
bool paused, done;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct timespec THREAD_SLEEP = {.tv_nsec = 5000};
|
||||||
int thread_simulation_iterate(void *ptr)
|
int thread_simulation_iterate(void *ptr)
|
||||||
{
|
{
|
||||||
struct ThreadState *state = ptr;
|
struct ThreadState *state = ptr;
|
||||||
@@ -38,6 +39,7 @@ int thread_simulation_iterate(void *ptr)
|
|||||||
{
|
{
|
||||||
while (state->paused && !state->done)
|
while (state->paused && !state->done)
|
||||||
{
|
{
|
||||||
|
thrd_sleep(&THREAD_SLEEP, NULL);
|
||||||
}
|
}
|
||||||
simulation_iterate(state->simulation);
|
simulation_iterate(state->simulation);
|
||||||
}
|
}
|
||||||
@@ -51,6 +53,7 @@ int thread_simulation_mutate(void *ptr)
|
|||||||
{
|
{
|
||||||
while (state->paused && !state->done)
|
while (state->paused && !state->done)
|
||||||
{
|
{
|
||||||
|
thrd_sleep(&THREAD_SLEEP, NULL);
|
||||||
}
|
}
|
||||||
simulation_mutate(state->simulation);
|
simulation_mutate(state->simulation);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user