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

Merge branch 'feature-fsm' into develop

This commit is contained in:
Steffen Vogel 2015-11-23 19:57:18 +01:00
commit 284e05f7a5
4 changed files with 38 additions and 4 deletions

View file

@ -163,6 +163,13 @@ struct node
int combine; /**< Number of messages to send / recv at once (scatter / gather) */
int affinity; /**< CPU Affinity of this node */
enum node_state {
NODE_INVALID, /**< This node object is not in a valid state. */
NODE_CREATED, /**< This node has been parsed from the configuration. */
NODE_RUNNING, /**< This node has been started by calling node_open() */
NODE_STOPPED /**< Node was running, but has been stopped by calling node_close() */
} state; /**< Node state */
struct node_type *_vt; /**< C++ like virtual function call table */
union {

View file

@ -31,6 +31,13 @@
*/
struct path
{
enum {
PATH_INVALID, /**< */
PATH_CREATED, /**< */
PATH_RUNNING, /**< */
PATH_STOPPED /**< */
} state; /**< Path state */
struct node *in; /**< Pointer to the incoming node */
struct node *out; /**< Pointer to the first outgoing node ( path::out == list_first(path::destinations) */

View file

@ -70,20 +70,33 @@ int node_deinit()
int node_start(struct node *n)
{ INDENT
info("Starting node '%s' of type '%s' (%s)", n->name, n->_vt->name, node_print(n));
int ret;
info("Starting node '%s' of type '%s' (%s)", n->name, n->_vt->name, node_print(n));
{ INDENT
return node_open(n);
ret = node_open(n);
}
if (ret == 0)
n->state = NODE_RUNNING;
return ret;
}
int node_stop(struct node *n)
{ INDENT
int ret;
info("Stopping node '%s'", n->name);
{ INDENT
return node_close(n);
ret = node_close(n);
}
if (ret == 0)
n->state = NODE_STOPPED;
return ret;
}
char * node_print(struct node *n)
@ -106,6 +119,7 @@ struct node * node_create(struct node_type *vt)
list_push(&vt->instances, n);
n->_vt = vt;
n->state = NODE_CREATED;
return n;
}

View file

@ -166,8 +166,10 @@ int path_start(struct path *p)
pthread_create(&p->sent_tid, NULL, &path_run_async, p);
}
p->state = PATH_RUNNING;
return pthread_create(&p->recv_tid, NULL, &path_run, p);
return pthread_create(&p->recv_tid, NULL, &path_run, p);
}
int path_stop(struct path *p)
@ -183,6 +185,8 @@ int path_stop(struct path *p)
close(p->tfd);
}
p->state = PATH_STOPPED;
if (path_run_hook(p, HOOK_PATH_STOP))
return -1;
@ -215,6 +219,8 @@ struct path * path_create()
if (h->type & HOOK_INTERNAL)
list_push(&p->hooks, memdup(h, sizeof(*h)));
}
p->state = PATH_CREATED;
return p;
}