Changeset e2cc3c7 for tests/concurrent/futures
- Timestamp:
- Apr 15, 2021, 3:43:04 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 78d6c803, 92b9958
- Parents:
- 84cd72d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/futures/multi.cfa
r84cd72d re2cc3c7 5 5 6 6 thread Server { 7 int cnt, iteration;7 int pending, done, iteration; 8 8 multi_future(int) * request; 9 9 }; … … 11 11 void ?{}( Server & this ) { 12 12 ((thread&)this){"Server Thread"}; 13 this.cnt = 0; 13 this.pending = 0; 14 this.done = 0; 14 15 this.iteration = 0; 15 16 this.request = 0p; … … 17 18 18 19 void ^?{}( Server & mutex this ) { 19 assert(this. cnt== 0);20 20 assert(this.pending == 0); 21 this.request = 0p; 21 22 } 22 23 … … 25 26 } 26 27 27 void process( Server & mutex this ) { 28 fulfil( *this.request, this.iteration ); 29 this.iteration++; 28 void call( Server & mutex this ) { 29 this.pending++; 30 30 } 31 31 32 void call( Server & mutex this ) {33 this. cnt++;32 void finish( Server & mutex this ) { 33 this.done++; 34 34 } 35 35 36 void finish( Server & mutex this ) { }37 38 36 void main( Server & this ) { 37 MAIN_LOOP: 39 38 for() { 40 39 waitfor( ^?{} : this ) { 41 40 break; 42 41 } 43 or when( this.cnt < NFUTURES ) waitfor( call: this ) { 44 if (this.cnt == NFUTURES) { 45 process(this); 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 ); 46 51 } 47 } 48 or waitfor( finish: this ) { 49 if (this.cnt == NFUTURES) { 50 reset( *this.request ); 51 this.cnt = 0; 52 } 52 53 reset( *this.request ); 54 this.done = 0; 53 55 } 54 56 }
Note: See TracChangeset
for help on using the changeset viewer.