module: remove ready_fd

All modules are expected to handle a call to content() after having
been instantiated.

I.e. modules *cannot* even expect run() to have started running.
This commit is contained in:
Daniel Eklöf 2019-01-13 15:25:39 +01:00
parent 65cfcfb2de
commit acdeff3b6e
14 changed files with 27 additions and 66 deletions

20
bar.c
View file

@ -537,14 +537,10 @@ run(struct bar_run_context *run_ctx)
struct module_run_context run_ctx_center[bar->center.count];
struct module_run_context run_ctx_right[bar->right.count];
int ready_fd = eventfd(0, EFD_CLOEXEC | EFD_SEMAPHORE);
assert(ready_fd != -1);
for (size_t i = 0; i < bar->left.count; i++) {
struct module_run_context *ctx = &run_ctx_left[i];
ctx->module = bar->left.mods[i];
ctx->ready_fd = ready_fd;
ctx->abort_fd = run_ctx->abort_fd;
thrd_create(&thrd_left[i], (int (*)(void *))bar->left.mods[i]->run, ctx);
@ -553,7 +549,6 @@ run(struct bar_run_context *run_ctx)
struct module_run_context *ctx = &run_ctx_center[i];
ctx->module = bar->center.mods[i];
ctx->ready_fd = ready_fd;
ctx->abort_fd = run_ctx->abort_fd;
thrd_create(&thrd_center[i], (int (*)(void *))bar->center.mods[i]->run, ctx);
@ -562,26 +557,13 @@ run(struct bar_run_context *run_ctx)
struct module_run_context *ctx = &run_ctx_right[i];
ctx->module = bar->right.mods[i];
ctx->ready_fd = ready_fd;
ctx->abort_fd = run_ctx->abort_fd;
thrd_create(&thrd_right[i], (int (*)(void *))bar->right.mods[i]->run, ctx);
}
LOG_DBG("waiting for modules to become ready");
for (size_t i = 0; i < (bar->left.count +
bar->center.count +
bar->right.count); i++) {
uint64_t b;
read(ready_fd, &b, sizeof(b));
}
close(ready_fd);
LOG_DBG("all modules started");
refresh(_bar);
int fd = xcb_get_file_descriptor(bar->conn);
while (true) {
@ -646,6 +628,8 @@ run(struct bar_run_context *run_ctx)
}
}
LOG_DBG("shutting down");
/* Wait for modules to terminate */
int ret = 0;
int mod_ret;