Changeset a882b68 for tests/concurrent/waituntil
- Timestamp:
- May 4, 2023, 2:39:52 PM (18 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- dd7a8ce
- Parents:
- cb69fba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/waituntil/channels.cfa
rcb69fba ra882b68 12 12 long long int a, b, c, i = 0, myTotal = 0; 13 13 for( ;;i++ ) { 14 when( i % 2 == 0 ) waituntil( (a << A)) { myTotal += a; }15 or when( i % 4 < 2 ) waituntil( (b << B)) { myTotal += b; }16 or waituntil( (c << C)) { if ( c == -1 ) break; myTotal += c; }14 when( i % 2 == 0 ) waituntil( a << A ) { myTotal += a; } 15 or when( i % 4 < 2 ) waituntil( b << B ) { myTotal += b; } 16 or waituntil( c << C ) { if ( c == -1 ) break; myTotal += c; } 17 17 or when( i % 8 < 4 ) else {} 18 18 } … … 22 22 thread Drainer {}; // ensures that the changing when states of Server1 don't result in a deadlock 23 23 void main( Drainer & this ) { 24 long long int a, b, c, i = 0, myTotal = 0; 25 for( ;;i++ ) { 26 waituntil( (a << A) ) { myTotal += a; } 27 or waituntil( (b << B) ) { myTotal += b; } 28 or waituntil( (c << C) ) { if ( c == -1 ) break; myTotal += c; } 24 long long int a, b, c, myTotal = 0; 25 for( ;; ) { 26 waituntil( a << A ) { myTotal += a; } 27 or waituntil( b << B ) { myTotal += b; } 28 or waituntil( c << C ) { if ( c == -1 ) break; myTotal += c; } 29 or else {} 29 30 } 30 31 __atomic_fetch_add( &globalTotal, myTotal, __ATOMIC_SEQ_CST ); … … 39 40 try_insert( B, 0 ); 40 41 try_insert( C, 0 ); 41 [out, success] = try_remove( A);42 [out, success] = try_remove( A ); 42 43 if ( success ) myTotal += out; 43 [out, success] = try_remove( B);44 [out, success] = try_remove( B ); 44 45 if ( success ) myTotal += out; 45 [out, success] = try_remove( C);46 [out, success] = try_remove( C ); 46 47 if ( success ) myTotal += out; 47 48 } … … 68 69 Churner c; 69 70 for( long long int j = 0; j < numtimes; j++ ) { 70 when( j % 2 == 0 ) waituntil( (j >> A)) { total += j; }71 or when( j % 4 < 2 ) waituntil( (j >> B)) { total += j; }72 and when( j % 8 < 4 ) waituntil( (j >> C)) { total += j; }71 when( j % 2 == 0 ) waituntil( j >> A ) { total += j; } 72 or when( j % 4 < 2 ) waituntil( j >> B ) { total += j; } 73 and when( j % 8 < 4 ) waituntil( j >> C ) { total += j; } 73 74 } 74 75 done = true; … … 76 77 } 77 78 printf("waiting for empty channels\n"); 78 while( get_count( A) > 0 || get_count(B) > 0 || get_count(C) > 0 ) { Pause();}79 while( get_count( A ) > 0 || get_count( B ) > 0 || get_count( C ) > 0 ) { } 79 80 printf("sending sentinels\n"); 80 81 for ( i; numServers + 1 ) insert( C, -1 );
Note: See TracChangeset
for help on using the changeset viewer.