-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_splitjoin.js
More file actions
executable file
·51 lines (42 loc) · 927 Bytes
/
test_splitjoin.js
File metadata and controls
executable file
·51 lines (42 loc) · 927 Bytes
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
#!/usr/bin/env node-fibers
var sluice = require('./sluice');
var println = console.log;
function Counter(limit)
{
this.n = limit;
this.cnt = 0;
this.reset = function() {
this.cnt = 0;
};
this.work = function() {
if (this.cnt >= this.n) return true;
this.push(++this.cnt);
return false;
};
}
function Adder(arg)
{
this.n = arg;
this.work = function() {
this.push(this.pop()+this.n);
return false;
};
}
function Printer()
{
this.work = function() {
println(this.pop());
return false;
};
}
var cnt = new Counter(10);
var sj = sluice.SplitRR(2, new Adder(1), new Adder(100), new Adder(1000)).JoinRR(1);
var p = sluice.Pipeline(cnt, sj, new Printer());
p.run();
cnt.reset();
p.run();
println("");println("");
cnt = new Counter(5);
sj = sluice.SplitDup(2, new Adder(-1), new Adder(-100), new Adder(-1000)).JoinRR(10);
p = sluice.Pipeline(cnt, sj, new Printer());
p.run();