Changeset 86b418f
- Timestamp:
- Nov 17, 2025, 9:04:40 PM (30 hours ago)
- Branches:
- master
- Children:
- b5749f9
- Parents:
- 822ae48
- File:
-
- 1 edited
-
tests/concurrency/waituntil/futures.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/waituntil/futures.cfa
r822ae48 r86b418f 1 #include < select.hfa>1 #include <fstream.hfa> 2 2 #include <future.hfa> 3 3 #include <thread.hfa> … … 5 5 future(int) A, B, C; 6 6 7 semaphore s{0}; 8 9 thread Server1 {}; 10 void main( Server1 & ) { 11 fulfil(B, 3); 12 P( s ); 13 fulfil(A, 2); 14 fulfil(C, 4); 15 } 16 17 thread Server2 {}; 18 void main( Server2 & ) { 19 fulfil(B, 6); 20 fulfil(A, 5); 21 fulfil(C, 7); 7 thread Server {}; 8 void main( Server & ) { 9 B( 3 ); // fulfil( B, 3 ); 10 A( 2 ); 11 C( 4 ); 22 12 } 23 13 24 14 int main() { 25 processor proc[1]; 26 printf("start\n"); // currently not working 27 { 28 Server1 s1; 29 waituntil( A ) { get(A); } 30 or waituntil( B ) { get(B); V( s ); } 31 and waituntil( C ) { get(C); } 32 } 33 reset(A); 34 reset(B); 35 reset(C); 36 for ( int i = 0; i < 8; i++ ) { 37 { 38 Server2 s2; 39 when( i % 2 == 0 ) waituntil( A ) { get(A); } 40 or when( i % 4 < 2 ) waituntil( B ) { get(B); } 41 and when( i < 4 ) waituntil( C ) { get(C); } 42 } 43 reset(A); 44 reset(B); 45 reset(C); 46 { 47 Server2 s2; 48 ( 49 when( i % 2 == 0 ) waituntil( A ) { get(A); } 50 or when( i % 4 < 2 ) waituntil( B ) { get(B); } 51 ) 52 and when( i < 4 ) waituntil( C ) { get(C); } 53 } 54 reset(A); 55 reset(B); 56 reset(C); 57 } 58 59 printf("end\n"); 60 return 0; 15 processor p; 16 sout | "start"; 17 { 18 size_t count = 0; 19 Server s; 20 for ( 3 ) { 21 waituntil( A ) { count += 1; A(); /* get( A ) */ reset( A ); } 22 or waituntil( B ) { count += 1; B(); reset( B ); } 23 or waituntil( C ) { count += 1; C(); reset( C ); } 24 } 25 assert( count == 3 ); 26 } 27 { 28 size_t count = 0; 29 Server s; 30 for ( 2 ) { 31 waituntil( A ) { count += 1; A(); /* get( A ) */ reset( A ); } 32 or waituntil( B ) { count += 1; B(); reset( B ); } 33 and waituntil( C ) { count += 1; C(); reset( C ); } 34 } 35 assert( count == 3 ); 36 } 37 size_t count = 0; 38 for ( i; 8 ) { 39 { 40 Server s; 41 when( i % 2 == 0 ) waituntil( A ) { count += 1; A(); } 42 or when( i % 4 < 2 ) waituntil( B ) { count += 1; B(); } 43 and when( i < 4 ) waituntil( C ) { count += 1; C(); } 44 } 45 reset( A ); reset( B ); reset( C ); 46 { 47 Server s; 48 ( when( i % 2 == 0 ) waituntil( A ) { count += 1; A(); } 49 or when( i % 4 < 2 ) waituntil( B ) { count += 1; B(); } 50 ) and when( i < 4 ) waituntil( C ) { count += 1; C(); } 51 } 52 reset( A ); reset( B ); reset( C ); 53 } // for 54 assert( count == 19 ); 55 sout | "end"; 61 56 }
Note:
See TracChangeset
for help on using the changeset viewer.