Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/sleep.cfa

    rc457dc4 r7bd23ce  
    77}
    88
     9volatile int counter = 0;
     10
    911thread fast_sleeper {};
    1012void main(fast_sleeper &) {
     
    1214        for(i; 20) {
    1315                sleep(wait);
    14                 sout | acquire | "fast loop" | ((1 + i) * wait);
     16                __atomic_fetch_add( &counter, 1, __ATOMIC_RELAXED );
    1517        }
    1618}
     
    2022        Duration wait = 277`ms;
    2123        for(i; 4) {
    22 
    2324                sleep(wait);
    24                 sout | acquire | "slow loop" | ((1 + i) * wait);
     25                int val = __atomic_add_fetch( &counter, -5, __ATOMIC_RELAXED );
     26                if(val < -9) abort | "Value reached negative value:" | val;
    2527        }
    2628}
Note: See TracChangeset for help on using the changeset viewer.