Skip to content

Instantly share code, notes, and snippets.

@samgiles
Created April 23, 2014 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samgiles/11213299 to your computer and use it in GitHub Desktop.
Save samgiles/11213299 to your computer and use it in GitHub Desktop.
Simple producer, consumer example [occam-pi]
#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