source: tests/concurrency/waituntil/futures.cfa@ 8ffee9a

Last change on this file since 8ffee9a was b5749f9, checked in by Peter A. Buhr <pabuhr@…>, 5 weeks ago

fix design error in test waituntil/futures.cfa

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include <fstream.hfa>
2#include <future.hfa>
3#include <thread.hfa>
4
5future(int) A, B, C;
6
7thread Server {};
8void main( Server & ) {
9 B( 3 ); // fulfil( B, 3 );
10 A( 2 );
11 C( 4 );
12}
13
14int main() {
15 processor p;
16 sout | "start";
17 {
18 size_t count = 0;
19 Server s;
20 for ( ; count < 3; ) {
21 waituntil( A ) { count += 1; A(); /* get( A ) */ }
22 or waituntil( B ) { count += 1; B(); }
23 or waituntil( C ) { count += 1; C(); }
24 }
25 reset( A ); reset( B ); reset( C );
26 }
27 {
28 size_t count = 0;
29 Server s;
30 for ( ; count < 3; ) {
31 waituntil( A ) { count += 1; A(); /* get( A ) */ }
32 or waituntil( B ) { count += 1; B(); }
33 and waituntil( C ) { count += 1; C(); }
34 }
35 reset( A ); reset( B ); reset( C );
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 sout | "end";
55}
Note: See TracBrowser for help on using the repository browser.