mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
super_node: move execution of periodic hooks to super_node_periodic()
This commit is contained in:
parent
df3b02b55f
commit
c52c03265b
3 changed files with 49 additions and 32 deletions
|
@ -88,6 +88,9 @@ int super_node_stop(struct super_node *sn);
|
|||
/** Desctroy configuration object. */
|
||||
int super_node_destroy(struct super_node *sn);
|
||||
|
||||
/** Run periodic hooks of this super node. */
|
||||
int super_node_periodic(struct super_node *sn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -491,3 +491,48 @@ int super_node_destroy(struct super_node *sn)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int super_node_periodic(struct super_node *sn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
for (size_t i = 0; i < list_length(&sn->paths); i++) {
|
||||
struct path *p = (struct path *) list_at(&sn->paths, i);
|
||||
|
||||
if (p->state != STATE_STARTED)
|
||||
continue;
|
||||
|
||||
for (size_t j = 0; j < list_length(&p->hooks); j++) {
|
||||
struct hook *h = (struct hook *) list_at(&p->hooks, j);
|
||||
|
||||
ret = hook_periodic(h);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < list_length(&sn->nodes); i++) {
|
||||
struct node *n = (struct node *) list_at(&sn->nodes, i);
|
||||
|
||||
if (n->state != STATE_STARTED)
|
||||
continue;
|
||||
|
||||
for (size_t j = 0; j < list_length(&n->in.hooks); j++) {
|
||||
struct hook *h = (struct hook *) list_at(&n->in.hooks, j);
|
||||
|
||||
ret = hook_periodic(h);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < list_length(&n->out.hooks); j++) {
|
||||
struct hook *h = (struct hook *) list_at(&n->out.hooks, j);
|
||||
|
||||
ret = hook_periodic(h);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -177,38 +177,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
for (;;) {
|
||||
task_wait(&t);
|
||||
|
||||
for (size_t i = 0; i < list_length(&sn.paths); i++) {
|
||||
struct path *p = (struct path *) list_at(&sn.paths, i);
|
||||
|
||||
if (p->state != STATE_STARTED)
|
||||
continue;
|
||||
|
||||
for (size_t j = 0; j < list_length(&p->hooks); j++) {
|
||||
struct hook *h = (struct hook *) list_at(&p->hooks, j);
|
||||
|
||||
hook_periodic(h);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < list_length(&sn.nodes); i++) {
|
||||
struct node *n = (struct node *) list_at(&sn.nodes, i);
|
||||
|
||||
if (n->state != STATE_STARTED)
|
||||
continue;
|
||||
|
||||
for (size_t j = 0; j < list_length(&n->in.hooks); j++) {
|
||||
struct hook *h = (struct hook *) list_at(&n->in.hooks, j);
|
||||
|
||||
hook_periodic(h);
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < list_length(&n->out.hooks); j++) {
|
||||
struct hook *h = (struct hook *) list_at(&n->out.hooks, j);
|
||||
|
||||
hook_periodic(h);
|
||||
}
|
||||
}
|
||||
super_node_periodic(&sn);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue