diff --git a/include/villas/nodes/loopback.h b/include/villas/nodes/loopback.h index 75160e835..95006a4b6 100644 --- a/include/villas/nodes/loopback.h +++ b/include/villas/nodes/loopback.h @@ -45,7 +45,7 @@ struct sample; */ struct loopback { int queuelen; - + int queueflags; struct queue_signalled queue; struct pool pool; }; diff --git a/lib/nodes/loopback.c b/lib/nodes/loopback.c index 4bb23e25c..6f949e499 100644 --- a/lib/nodes/loopback.c +++ b/lib/nodes/loopback.c @@ -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)