home *** CD-ROM | disk | FTP | other *** search
- eos="eos";
- ch1=channel();
- ch2=channel();
- ch3=channel();
- n=0;
- task merge(inp1,inp2,out;x) {
- select {case inp1?x:if(x==eos) n=n+1; else out!x;if(n==2) exit;
- case inp2?x:if(x==eos) n=n+1; else out!x;if(n==2) exit;
- }};
-
- task source1(out) {out!1;out!3;out!eos;};
- task source2(out) {out!2;out!4;out!5;out!eos;};
- task sink(inp;x) {while (true) {inp?x;print x;}};
- task main() {start source1(ch1); start source2(ch2);start merge(ch1,ch2,ch3);
- start sink(ch3);};
- end
-