1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

loopback: add option for queue sync mode

This commit is contained in:
Steffen Vogel 2018-10-17 16:12:16 +02:00
parent 11bba98efe
commit e0a02c74f5
2 changed files with 22 additions and 4 deletions

View file

@ -45,7 +45,7 @@ struct sample;
*/
struct loopback {
int queuelen;
int queueflags;
struct queue_signalled queue;
struct pool pool;
};

View file

@ -29,19 +29,37 @@
int loopback_parse(struct node *n, json_t *cfg)
{
struct loopback *l = (struct loopback *) n->_vd;
const char *mode_str = NULL;
json_error_t err;
int ret;
/* Default values */
l->queueflags = QUEUE_SIGNALLED_AUTO;
l->queuelen = DEFAULT_QUEUE_LENGTH;
ret = json_unpack_ex(cfg, &err, 0, "{ s?: i }",
"queuelen", &l->queuelen
ret = json_unpack_ex(cfg, &err, 0, "{ s?: i, s?: s }",
"queuelen", &l->queuelen,
"mode", &mode_str
);
if (ret)
jerror(&err, "Failed to parse configuration of node %s", node_name(n));
if (mode_str) {
if (!strcmp(mode_str, "eventfd"))
l->queueflags = QUEUE_SIGNALLED_EVENTFD;
else if (!strcmp(mode_str, "pthread"))
l->queueflags = QUEUE_SIGNALLED_PTHREAD;
#ifdef __APPLE__
else if (!strcmp(mode_str, "polling"))
l->queueflags = QUEUE_SIGNALLED_POLLING;
#endif /* __APPLE__ */
else if (!strcmp(mode_str, "pipe"))
l->queueflags = QUEUE_SIGNALLED_PIPE;
else
error("Unknown mode '%s' in node %s", mode_str, node_name(n));
}
return 0;
}
@ -54,7 +72,7 @@ int loopback_start(struct node *n)
if (ret)
return ret;
return queue_signalled_init(&l->queue, l->queuelen, &memory_hugepage, QUEUE_SIGNALLED_EVENTFD);
return queue_signalled_init(&l->queue, l->queuelen, &memory_hugepage, l->queueflags);
}
int loopback_stop(struct node *n)