Ignore:
Timestamp:
Dec 6, 2017, 8:01:23 AM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
16988e8
Parents:
65197c2
Message:

add "with" clause to test programs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/coroutine/prodcons.c

    r65197c2 r971d9f2  
    1010// Created On       : Mon Sep 18 12:23:39 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Oct 30 23:06:05 2017
    13 // Update Count     : 42
     12// Last Modified On : Tue Dec  5 22:40:55 2017
     13// Update Count     : 46
    1414//
    1515
     
    2424
    2525coroutine Prod {
    26         Cons *c;
     26        Cons * c;
    2727        int N, money, receipt;
    2828};
    29 void main( Prod & prod ) {                                                              // starter ::main
     29void main( Prod & prod ) with( prod ) {                                 // starter ::main
    3030        // 1st resume starts here
    31         for ( int i = 0; i < prod.N; i += 1 ) {
     31        for ( int i = 0; i < N; i += 1 ) {
    3232                int p1 = random( 100 );
    3333                int p2 = random( 100 );
    3434                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;
    3737                sout | status | endl;
    38                 prod.receipt += 1;
     38                receipt += 1;
    3939        }
    40         stop( *prod.c );
     40        stop( *c );
    4141        sout | "prod stops" | endl;
    4242}
     
    6464}
    6565void ^?{}( Cons & cons ) {}
    66 void main( Cons & cons ) {                                                              // starter prod
     66void main( Cons & cons ) with( cons ) {                                 // starter prod
    6767        // 1st resume starts here
    6868        int money = 1, receipt;
    69         for ( ; ! cons.done; ) {
    70                 sout | cons.p1 | " " | cons.p2 | endl;
     69        for ( ; ! done; ) {
     70                sout | p1 | " " | p2 | endl;
    7171                sout | " $" | money | endl;
    72                 cons.status += 1;
    73                 receipt = payment( *cons.p, money );
     72                status += 1;
     73                receipt = payment( *p, money );
    7474                sout | " #" | receipt | endl;
    7575                money += 1;
Note: See TracChangeset for help on using the changeset viewer.