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