Ignore:
Timestamp:
Oct 29, 2019, 4:01:24 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
773db65, 9421f3d8
Parents:
7951100 (diff), 8364209 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 moved

Legend:

Unmodified
Added
Removed
  • tests/concurrent/examples/datingService.cfa

    r7951100 rb067d9b  
    11//
     2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     3//
    24// The contents of this file are covered under the licence agreement in the
    35// file "LICENCE" distributed with Cforall.
     
    810// Created On       : Mon Oct 30 12:56:20 2017
    911// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Sun May 27 09:05:18 2018
    11 // Update Count     : 26
     12// Last Modified On : Fri Jun 21 11:32:34 2019
     13// Update Count     : 38
    1214//
    1315
    14 #include <stdlib>                                                                               // random
    15 #include <fstream>
    16 #include <kernel>
    17 #include <thread>
     16#include <stdlib.hfa>                                                                   // random
     17#include <fstream.hfa>
     18#include <kernel.hfa>
     19#include <thread.hfa>
    1820#include <unistd.h>                                                                             // getpid
    1921
     
    3335                signal_block( Boys[ccode] );                                    // restart boy to set phone number
    3436        } // if
     37        sout | "Girl:" | PhoneNo | "is dating Boy at" | BoyPhoneNo | "with ccode" | ccode;
    3538        return BoyPhoneNo;
    3639} // DatingService girl
     
    4447                signal_block( Girls[ccode] );                                   // restart girl to set phone number
    4548        } // if
     49        sout | " Boy:" | PhoneNo | "is dating Girl" | GirlPhoneNo | "with ccode" | ccode;
    4650        return GirlPhoneNo;
    4751} // DatingService boy
     
    5862        yield( random( 100 ) );                                                         // don't all start at the same time
    5963        unsigned int partner = girl( TheExchange, id, ccode );
    60         sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode | endl;
    6164        girlck[id] = partner;
    6265} // Girl main
     
    6972
    7073thread Boy {
    71         DatingService &TheExchange;
     74        DatingService & TheExchange;
    7275        unsigned int id, ccode;
    7376}; // Boy
     
    7679        yield( random( 100 ) );                                                         // don't all start at the same time
    7780        unsigned int partner = boy( TheExchange, id, ccode );
    78         sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode | endl;
    7981        boyck[id] = partner;
    8082} // Boy main
     
    9395        srandom( /*getpid()*/ 103 );
    9496
    95         for ( unsigned int i = 0; i < CompCodes; i += 1 ) {
    96                 girls[i] = new( &TheExchange, i, i );
     97        for ( i; (unsigned int)CompCodes ) {
     98                girls[i] = new( &TheExchange, i, i );                   // TheExchange constructor needs unsigned int
    9799                boys[i]  = new( &TheExchange, i, CompCodes - ( i + 1 ) );
    98100        } // for
    99101
    100         for ( unsigned int i = 0; i < CompCodes; i += 1 ) {
     102        for ( i; CompCodes ) {
    101103                delete( boys[i] );
    102104                delete( girls[i] );
    103105        } // for
    104106
    105         for ( unsigned int i = 0; i < CompCodes; i += 1 ) {
     107        for ( i; CompCodes ) {
    106108                if ( girlck[ boyck[i] ] != boyck[ girlck[i] ] ) abort();
    107109        } // for
     
    110112// Local Variables: //
    111113// tab-width: 4 //
    112 // compile-command: "cfa datingService.c" //
     114// compile-command: "cfa datingService.cfa" //
    113115// End: //
Note: See TracChangeset for help on using the changeset viewer.