bar: wait for all modules to have started up before continuing

After starting all the module threads, wait for all modules to have
signalled "ready" before continuing.

This will allow modules to do initial setup, and knowing that
content() will *not* be called until they've signalled "ready".
This commit is contained in:
Daniel Eklöf 2018-12-19 19:41:25 +01:00
parent 7f0f096ba4
commit a3eb7ebc08
8 changed files with 35 additions and 1 deletions

View file

@ -1,6 +1,8 @@
#include "clock.h"
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include <assert.h>
#include <poll.h>
@ -50,6 +52,8 @@ run(struct module_run_context *ctx)
{
const struct bar *bar = ctx->module->bar;
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
while (true) {
time_t now = time(NULL);
time_t now_no_secs = now / 60 * 60;