anrienord's tumblelog RSS

I'm not sure that having a tumblelog is a good idea. Nevertheless it worth trying.
Andrey Nordin
May
21st
Mon
permalink
run := prog(
    data: chan of array of char,
    exit: chan of unit) {
  str: array of char;
  for(;;)
    select {
      case str = <-data:
        print("received", str, "\n");
      case <-exit:
        become unit; # return
    }
};

data := mk(chan of array of char);
exit := mk(chan of unit);

begin run(data, exit);

data <-= "hello";
data <-= "world";
exit <-= unit;
— a code in newsqueak by rob pike, “introduction to concurrent programming”. explicit parallel invocation, no shared memory semantics

bookmarks: del.icio.us  technorati