/* Here we pack contexts into a structure and demonstrate a few things */ typedef struct { @share @stream s1; @share s2; @share @single s3; @share @reply s4; } biggie; /* This is legal... we can pass pointers around between functions, but not * into a process */ init_big(biggie *b) { @init(b->s1); @init(b->s2); @init(b->s3); @init(b->s4); } @process hi(biggie b) { int i; i=1; @write(b.s1,i); i=2; @write(b.s2,i); i=4; @write(b.s2,i); /* Writing into a singleton... the second value will replace the first */ i=3; @write(b.s3,i); i=5; @write(b.s3,i); @resource (b.s4,i) { /* We can put any code we like into here */ i*=13; } @reply i; } eMain() { int i; biggie x; init_big(&x); @subordinate hi(x); @get(x.s1,i); printf("Got %d from s1\n",i); /* printf's are fine... but it's usually a good idea to put them all * in the eMain process (is safer across different environments) */ @get(x.s2,i); printf("Got %d from s2\n",i); @get(x.s2,i); printf("Got %d from s2\n",i); @get(x.s3,i); printf("Got %d from s3\n",i); i=10; @call(x.s4,i,i); printf("Got %d from s4\n",i); }