blob: 8f51f62818d70a6839c0f7ff41842ddbc5759e5e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include <stdio.h>
#include "parapat.h"
typedef struct {
int v;
} arg_t;
void *test_work(void *v) {
arg_t *a = v;
a->v *= 2;
return a;
}
void *test_fold(void *a, void *b) {
arg_t *x = a, *y = b;
x->v += y->v;
return x;
}
int main() {
int i;
arg_t a, *res = &a;
arg_t args[10];
arg_t *ptrs[10];
work *fns[4] = {
&test_work,
&test_work,
&test_work,
&test_work
};
pipeline *pl;
for (i = 0; i < 10; ++i) {
args[i].v = i;
ptrs[i] = &args[i];
}
a.v = 0;
res = create_farm(&test_work, &test_fold, 10, (void **) &ptrs[0]);
printf("after farm: %d\n", res->v);
pl = create_pipeline(fns, 4);
push(pl->in, res);
res = pop(pl->out);
printf("after pipeline: %d\n", res->v);
return 0;
}
|