Changeset 3aa1d22 for tests/concurrent/examples/boundedBufferINT.cfa
- Timestamp:
- Jun 21, 2019, 11:46:55 AM (5 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:
- 49dee5e
- Parents:
- d38c4b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/boundedBufferINT.cfa
rd38c4b4 r3aa1d22 10 10 // Created On : Mon Oct 30 12:45:13 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 22 13:41:52201913 // Update Count : 8812 // Last Modified On : Fri Jun 21 08:20:46 2019 13 // Update Count : 90 14 14 // 15 15 … … 53 53 } 54 54 55 const int Sentinel = -1;55 enum { Sentinel = -1 }; 56 56 57 57 thread Producer { … … 60 60 }; 61 61 void main( Producer & prod ) with( prod ) { 62 for ( i nt i = 1; i <= N; i += 1) {62 for ( i; 1 ~= N ) { 63 63 yield( random( 5 ) ); 64 64 insert( buffer, 1 ); … … 100 100 srandom( 1003 ); 101 101 102 for ( i = 0; i < Cons; i += 1 ) {// create consumers102 for ( i; Cons ) { // create consumers 103 103 cons[i] = new( &buffer, sums[i] ); 104 104 } // for 105 for ( i = 0; i < Prods; i += 1 ) {// create producers105 for ( i; Prods ) { // create producers 106 106 prods[i] = new( &buffer, 100000 ); 107 107 } // for 108 108 109 for ( i = 0; i < Prods; i += 1 ) {// wait for producers to finish109 for ( i; Prods ) { // wait for producers to finish 110 110 delete( prods[i] ); 111 111 } // for 112 for ( i = 0; i < Cons; i += 1 ) {// generate sentinal values to stop consumers112 for ( i; Cons ) { // generate sentinal values to stop consumers 113 113 insert( buffer, Sentinel ); 114 114 } // for 115 115 int sum = 0; 116 for ( i = 0; i < Cons; i += 1 ) {// wait for consumers to finish116 for ( i; Cons ) { // wait for consumers to finish 117 117 delete( cons[i] ); 118 118 sum += sums[i];
Note: See TracChangeset
for help on using the changeset viewer.