source: tests/concurrency/once.cfa @ 5668740

Last change on this file since 5668740 was c26bea2a, checked in by Peter A. Buhr <pabuhr@…>, 17 months ago

first attempt at renaming directory tests/concurrent to tests/concurrency to harmonize with other concurrency directory names

  • Property mode set to 100644
File size: 648 bytes
Line 
1#include <barrier.hfa>
2#include <fstream.hfa>
3#include <kernel.hfa>
4#include <once.hfa>
5#include <thread.hfa>
6
7once_flag global;
8
9volatile int check;
10
11void reset() {
12        (global){};
13        check = 0;
14}
15
16void must_once(void) {
17        int prev = __atomic_fetch_add( &check, 1, __ATOMIC_SEQ_CST );
18        if(prev != 0) {
19                abort | "'must_once' appears to have been called more than once, check was" | prev;
20        }
21}
22
23barrier barr = { 11 };
24
25thread Tester {};
26
27void main( Tester & this ) {
28        for(500) {
29                block( barr, reset );
30
31                // sometime yields
32                yield( prng(this, 3) );
33        }
34}
35
36int main() {
37        processor p[2];
38
39        sout | "starting";
40        {
41                Tester testers[11];
42        }
43        sout | "done";
44}
Note: See TracBrowser for help on using the repository browser.