| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.9 - 28 Apr 2005 - TWikiGuest) |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.8 - 26 Jan 2005 - LiYan) |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.7 - 19 Jan 2005 - ArjanB) |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.6 - 27 Feb 2004 - IsaacGouy) |
| Changed: | |
| < < | do { |
| > > | while (count < MAX){ |
| Changed: | |
| < < | } while(count < MAX); |
| > > | } |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.5 - 26 Feb 2004 - IsaacGouy) |
| Deleted: | |
| < < | let One2OneChannelInt done = new One2OneChannelInt(); |
| Deleted: | |
| < < | let m = new ProcessManager?( |
| Changed: | |
| < < | ])); m.start; done.read; m.stop; |
| > > | ]).run; |
| Changed: | |
| < < | while(count < MAX){ |
| > > | do { |
| Changed: | |
| < < | } done.write(0); |
| > > | } while(count < MAX); System.exit(0); |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.4 - 26 Feb 2004 - IsaacGouy) |
| Added: | |
| > > | let One2OneChannelInt done = new One2OneChannelInt(); |
| Added: | |
| > > | let m = new ProcessManager?( |
| Changed: | |
| < < | seq( ()=>{ c.consume(); } ) ,seq( ()=>{ p.produce; } ) ]).run; |
| > > | seq( ()=>{ p.produce; } ) ,seq( ()=>{ c.consume; } ) ])); m.start; done.read; m.stop; |
| Added: | |
| > > | |
| Changed: | |
| < < | while(count < MAX){ count++; channel.write(count); } |
| > > | while(true) channel.write(++count); |
| Added: | |
| > > | done.write(0); |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.3 - 24 Feb 2004 - IsaacGouy) |
| Changed: | |
| < < | ()=>{ c.consume(); } ,()=>{ p.produce(); } ]); |
| > > | seq( ()=>{ c.consume(); } ) ,seq( ()=>{ p.produce; } ) ]).run; |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.2 - 24 Feb 2004 - IsaacGouy) |
| Changed: | |
| < < | let p = new Producer(channel: chan); let c = new Consumer(channel: chan); |
| > > | let p = new ProdCon?(channel: chan); let c = new ProdCon?(channel: chan); |
| Changed: | |
| < < | class Producer { |
| > > | class ProdCon? { |
| Deleted: | |
| < < | } class Consumer { One2OneChannelInt channel; int count = 0; |
| Added: | |
| > > | Compare with Java at the "Win32 Language Shootout" Compare with Nice using Java concurrency in the "Language Shootout Examples" |
| Added: | |
| > > | Experimental use of the "Communicating Sequential Processes for Java TM (JCSP)" library. |
| Changed: | |
| < < | |
| > > | >java -cp "jcspclasses.jar;prodcons.jar" prodcons.fun Consumed 1 Consumed 2 Consumed 3 Consumed 4 Consumed 5 |
| <<O>> Difference Topic SimpleProducerConsumerCspExample (r1.1 - 24 Feb 2004 - IsaacGouy) |
| Added: | |
| > > |
%META:TOPICINFO{author="IsaacGouy" date="1077589260" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="CodeExamples"}%
/* Please try the NoviceExamples before these examples
To compile:
>nicec --classpath "jcspclasses.jar;nice-csp.jar" --sourcepath .. -a prodcons.jar prodcons
To run:
java -cp "jcspclasses.jar;prodcons.jar" prodcons.fun
*/
import nice.csp;
let int MAX = 5;
void main(String[] args){
let chan = new One2OneChannelInt();
let p = new Producer(channel: chan);
let c = new Consumer(channel: chan);
par ([
()=>{ c.consume(); }
,()=>{ p.produce(); }
]);
}
class Producer {
One2OneChannelInt channel;
int count = 0;
void produce(){
while(count < MAX){
count++;
channel.write(count);
}
}
}
class Consumer {
One2OneChannelInt channel;
int count = 0;
void consume(){
while(count < MAX){
count = channel.read;
println("Consumed " + count);
}
}
}
/* Notes - language
*/
-- IsaacGouy - 24 Feb 2004 |
| Topic SimpleProducerConsumerCspExample . { View | Diffs | r1.9 | > | r1.8 | > | r1.7 | More } |
|
Revision r1.1 - 24 Feb 2004 - 02:21 GMT - IsaacGouy Revision r1.9 - 28 Apr 2005 - 11:55 GMT - TWikiGuest |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |