wip: initial multithreaded renderer

This commit is contained in:
Daniel Eklöf 2019-07-29 20:13:26 +02:00
parent d1b88f67e4
commit c531795b83
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 287 additions and 89 deletions

View file

@ -107,26 +107,28 @@ get_config_path(void)
}
static bool
str_to_color(const char *s, uint32_t *color, const char *path, int lineno)
str_to_ulong(const char *s, int base, unsigned long *res)
{
if (s == NULL)
return false;
errno = 0;
char *end = NULL;
unsigned long res = strtoul(s, &end, 16);
if (errno != 0) {
*res = strtoul(s, &end, base);
return errno == 0 && *end == '\0';
}
static bool
str_to_color(const char *s, uint32_t *color, const char *path, int lineno)
{
unsigned long value;
if (!str_to_ulong(s, 16, &value)) {
LOG_ERRNO("%s:%d: invalid color: %s", path, lineno, s);
return false;
}
if (*end != '\0') {
LOG_ERR("%s:%d: invalid color: %s", path, lineno, s);
return false;
}
*color = res & 0xffffff;
*color = value & 0xffffff;
return true;
}
@ -149,6 +151,15 @@ parse_section_main(const char *key, const char *value, struct config *conf,
conf->font = strdup(value);
}
else if (strcmp(key, "workers") == 0) {
unsigned long count;
if (!str_to_ulong(value, 10, &count)) {
LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value);
return false;
}
conf->render_worker_count = count;
}
else {
LOG_WARN("%s:%u: invalid key: %s", path, lineno, key);
return false;
@ -427,6 +438,8 @@ config_load(struct config *conf)
.cursor = 0,
},
},
.render_worker_count = sysconf(_SC_NPROCESSORS_ONLN),
};
char *path = get_config_path();