source: tests/concurrent/once.cfa @ 8463136

ast-experimental
Last change on this file since 8463136 was 7bc84b8, checked in by Peter A. Buhr <pabuhr@…>, 2 years ago

remove unsigned cast for prng calls

  • Property mode set to 100644
File size: 648 bytes
RevLine 
[e8b8e65]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
[7bc84b8]32                yield( prng(this, 3) );
[e8b8e65]33        }
34}
35
36int main() {
37        processor p[2];
38
39        sout | "starting";
40        {
41                Tester testers[11];
42        }
43        sout | "done";
[d2ad151]44}
Note: See TracBrowser for help on using the repository browser.