Changeset b067d9b for tests/concurrent/examples/datingService.cfa
- Timestamp:
- Oct 29, 2019, 4:01:24 PM (6 years ago)
- 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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/datingService.cfa
r7951100 rb067d9b 1 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 // 2 4 // The contents of this file are covered under the licence agreement in the 3 5 // file "LICENCE" distributed with Cforall. … … 8 10 // Created On : Mon Oct 30 12:56:20 2017 9 11 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Sun May 27 09:05:18 201811 // Update Count : 2612 // Last Modified On : Fri Jun 21 11:32:34 2019 13 // Update Count : 38 12 14 // 13 15 14 #include <stdlib >// random15 #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> 18 20 #include <unistd.h> // getpid 19 21 … … 33 35 signal_block( Boys[ccode] ); // restart boy to set phone number 34 36 } // if 37 sout | "Girl:" | PhoneNo | "is dating Boy at" | BoyPhoneNo | "with ccode" | ccode; 35 38 return BoyPhoneNo; 36 39 } // DatingService girl … … 44 47 signal_block( Girls[ccode] ); // restart girl to set phone number 45 48 } // if 49 sout | " Boy:" | PhoneNo | "is dating Girl" | GirlPhoneNo | "with ccode" | ccode; 46 50 return GirlPhoneNo; 47 51 } // DatingService boy … … 58 62 yield( random( 100 ) ); // don't all start at the same time 59 63 unsigned int partner = girl( TheExchange, id, ccode ); 60 sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode | endl;61 64 girlck[id] = partner; 62 65 } // Girl main … … 69 72 70 73 thread Boy { 71 DatingService & TheExchange;74 DatingService & TheExchange; 72 75 unsigned int id, ccode; 73 76 }; // Boy … … 76 79 yield( random( 100 ) ); // don't all start at the same time 77 80 unsigned int partner = boy( TheExchange, id, ccode ); 78 sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode | endl;79 81 boyck[id] = partner; 80 82 } // Boy main … … 93 95 srandom( /*getpid()*/ 103 ); 94 96 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 97 99 boys[i] = new( &TheExchange, i, CompCodes - ( i + 1 ) ); 98 100 } // for 99 101 100 for ( unsigned int i = 0; i < CompCodes; i += 1) {102 for ( i; CompCodes ) { 101 103 delete( boys[i] ); 102 104 delete( girls[i] ); 103 105 } // for 104 106 105 for ( unsigned int i = 0; i < CompCodes; i += 1) {107 for ( i; CompCodes ) { 106 108 if ( girlck[ boyck[i] ] != boyck[ girlck[i] ] ) abort(); 107 109 } // for … … 110 112 // Local Variables: // 111 113 // tab-width: 4 // 112 // compile-command: "cfa datingService.c " //114 // compile-command: "cfa datingService.cfa" // 113 115 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.