Ignore:
Timestamp:
Apr 1, 2022, 12:40:35 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
1417f6b
Parents:
93b8cf4
Message:

Added comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/barrier/generation.cfa

    r93b8cf4 r31ef267  
    1515//
    1616
     17// Test validates barrier by having each thread print ABCD...
     18// If the barrier is correct it should print all As, all Bs, etc.
    1719
    18 int NUM_THREADS = 9;
    19 int NUM_LAPS = 53;
     20unsigned NUM_THREADS = 9;
     21unsigned NUM_LAPS = 53;
    2022
    2123#include <concurrency/barrier.hfa>
     
    2426#include <thread.hfa>
    2527
     28// The barrier we are testing
    2629barrier bar = { NUM_THREADS };
     30
    2731
    2832thread Tester {};
    2933void main( Tester & this ) {
     34        // Repeat the experiment a few times
    3035        for(NUM_LAPS)
     36                // For each letters
    3137                for(c; 'A' ~= 'Z') {
     38                        // Yield for chaos
    3239                        yield(prng(this, 10));
     40
     41                        // Print the generation, no newline because
    3342                        mutex(sout) sout | c | nonl;
     43
     44                        // Yield again for more chaos
    3445                        yield(prng(this, 10));
     46
     47                        // Block on the barrier
    3548                        block(bar);
    3649                }
Note: See TracChangeset for help on using the changeset viewer.