Created
April 23, 2014 12:27
-
-
Save samgiles/11213299 to your computer and use it in GitHub Desktop.
Simple producer, consumer example [occam-pi]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "course.module" | |
PROC producer(VAL INT start, step, CHAN OF INT c!) | |
INT count: | |
SEQ | |
count := start | |
WHILE TRUE | |
SEQ | |
c ! count | |
count := count + step | |
: | |
PROC main(CHAN BYTE kyb?, scr!, err!) | |
CHAN OF INT c: | |
INITIAL INT n IS 0: | |
INT val: | |
PAR | |
producer(0, 4, c!) | |
WHILE n < 10 | |
SEQ | |
c ? val | |
out.int (val, 0, scr!) | |
out.string ("*n", 0, scr!) | |
n := n + 1 | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment