dol: initial dol commit
[jump.git] / dol / examples / examplewindowedfifo / src / consumer.c
1 #include <stdio.h>
2
3 #include "consumer.h"
4
5 void consumer_init(DOLProcess *p) {
6     sprintf(p->local->name, "consumer");
7     p->local->index = 0;
8     p->local->len = LENGTH;
9 }
10
11 int consumer_fire(DOLProcess *p) {
12     float *c;
13     if (p->local->index < p->local->len) {
14         DOL_capture((void*)PORT_IN, &c, sizeof(float), p);
15         printf("%s: %f\n", p->local->name, *c);
16         DOL_consume((void*)PORT_IN, p);
17         p->local->index++;
18     }
19
20     if (p->local->index >= p->local->len) {
21         DOL_detach(p);
22         return -1;
23     }
24
25     return 0;
26 }
27