Ignore:
Timestamp:
Apr 15, 2021, 3:43:04 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

Attempted fix of multi future test by making server monitor more strict.
It is still not clear that this test stresses futures significantly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/futures/multi.cfa

    r84cd72d re2cc3c7  
    55
    66thread Server {
    7         int cnt, iteration;
     7        int pending, done, iteration;
    88        multi_future(int) * request;
    99};
     
    1111void ?{}( Server & this ) {
    1212        ((thread&)this){"Server Thread"};
    13         this.cnt = 0;
     13        this.pending = 0;
     14        this.done = 0;
    1415        this.iteration = 0;
    1516        this.request = 0p;
     
    1718
    1819void ^?{}( Server & mutex this ) {
    19         assert(this.cnt == 0);
    20     this.request = 0p;
     20        assert(this.pending == 0);
     21        this.request = 0p;
    2122}
    2223
     
    2526}
    2627
    27 void process( Server & mutex this ) {
    28         fulfil( *this.request, this.iteration );
    29         this.iteration++;
     28void call( Server & mutex this ) {
     29        this.pending++;
    3030}
    3131
    32 void call( Server & mutex this ) {
    33         this.cnt++;
     32void finish( Server & mutex this ) {
     33        this.done++;
    3434}
    3535
    36 void finish( Server & mutex this ) { }
    37 
    3836void main( Server & this ) {
     37        MAIN_LOOP:
    3938        for() {
    4039                waitfor( ^?{} : this ) {
    4140                        break;
    4241                }
    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 );
    4651                        }
    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;
    5355                }
    5456        }
Note: See TracChangeset for help on using the changeset viewer.