Changes in src/tests/coroutine/prodcons.c [557435e:971d9f2]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/coroutine/prodcons.c
r557435e r971d9f2 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 23:06:05 201713 // Update Count : 4 212 // Last Modified On : Tue Dec 5 22:40:55 2017 13 // Update Count : 46 14 14 // 15 15 … … 24 24 25 25 coroutine Prod { 26 Cons * c;26 Cons * c; 27 27 int N, money, receipt; 28 28 }; 29 void main( Prod & prod ) {// starter ::main29 void main( Prod & prod ) with( prod ) { // starter ::main 30 30 // 1st resume starts here 31 for ( int i = 0; i < prod.N; i += 1 ) {31 for ( int i = 0; i < N; i += 1 ) { 32 32 int p1 = random( 100 ); 33 33 int p2 = random( 100 ); 34 34 sout | p1 | " " | p2 | endl; 35 int status = delivery( * prod.c, p1, p2 );36 sout | " $" | prod.money | endl;35 int status = delivery( *c, p1, p2 ); 36 sout | " $" | money | endl; 37 37 sout | status | endl; 38 prod.receipt += 1;38 receipt += 1; 39 39 } 40 stop( * prod.c );40 stop( *c ); 41 41 sout | "prod stops" | endl; 42 42 } … … 64 64 } 65 65 void ^?{}( Cons & cons ) {} 66 void main( Cons & cons ) {// starter prod66 void main( Cons & cons ) with( cons ) { // starter prod 67 67 // 1st resume starts here 68 68 int money = 1, receipt; 69 for ( ; ! cons.done; ) {70 sout | cons.p1 | " " | cons.p2 | endl;69 for ( ; ! done; ) { 70 sout | p1 | " " | p2 | endl; 71 71 sout | " $" | money | endl; 72 cons.status += 1;73 receipt = payment( * cons.p, money );72 status += 1; 73 receipt = payment( *p, money ); 74 74 sout | " #" | receipt | endl; 75 75 money += 1;
Note: See TracChangeset
for help on using the changeset viewer.