- File:
-
- 1 edited
-
tests/concurrent/futures/multi.cfa (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/futures/multi.cfa
re2cc3c7 r44e37ef 5 5 6 6 thread Server { 7 int pending, done, iteration;7 int cnt, iteration; 8 8 multi_future(int) * request; 9 9 }; 10 10 11 11 void ?{}( Server & this ) { 12 ((thread&)this){"Server Thread"}; 13 this.pending = 0; 14 this.done = 0; 12 this.cnt = 0; 15 13 this.iteration = 0; 16 14 this.request = 0p; … … 18 16 19 17 void ^?{}( Server & mutex this ) { 20 assert(this. pending== 0);21 this.request = 0p;18 assert(this.cnt == 0); 19 this.request = 0p; 22 20 } 23 21 … … 26 24 } 27 25 28 void call( Server & mutex this ) { 29 this.pending++; 26 void process( Server & mutex this ) { 27 fulfil( *this.request, this.iteration ); 28 this.iteration++; 30 29 } 31 30 32 void finish( Server & mutex this ) {33 this. done++;31 void call( Server & mutex this ) { 32 this.cnt++; 34 33 } 35 34 35 void finish( Server & mutex this ) { } 36 36 37 void main( Server & this ) { 37 MAIN_LOOP:38 38 for() { 39 39 waitfor( ^?{} : this ) { 40 40 break; 41 41 } 42 or waitfor( call: this ) { 43 if (this.pending != NFUTURES) { continue MAIN_LOOP; } 44 45 this.pending = 0; 46 fulfil( *this.request, this.iteration ); 47 this.iteration++; 48 49 for(NFUTURES) { 50 waitfor( finish: this ); 42 or when( this.cnt < NFUTURES ) waitfor( call: this ) { 43 if (this.cnt == NFUTURES) { 44 process(this); 51 45 } 52 53 reset( *this.request ); 54 this.done = 0; 46 } 47 or waitfor( finish: this ) { 48 if (this.cnt == NFUTURES) { 49 reset( *this.request ); 50 this.cnt = 0; 51 } 55 52 } 56 53 } … … 60 57 Server * the_server; 61 58 thread Worker {}; 62 void ?{}(Worker & this) {63 ((thread&)this){"Worker Thread"};64 }65 66 59 multi_future(int) * shared_future; 67 60
Note:
See TracChangeset
for help on using the changeset viewer.