source:
tests/concurrent/waitfor/else.cfa
@
4150779
Last change on this file since 4150779 was cca568e, checked in by , 5 years ago | |
---|---|
|
|
File size: 714 bytes |
Rev | Line | |
---|---|---|
[73abe95] | 1 | #include <fstream.hfa> |
2 | #include <monitor.hfa> | |
[4cc9b13] | 3 | |
4 | #include <stdbool.h> | |
5 | ||
6 | monitor M {}; | |
7 | ||
8 | void notcalled( M & mutex m ) { | |
9 | abort(); | |
10 | } | |
11 | ||
12 | void test( M & mutex m ) { | |
13 | int i = 0; | |
[200fcb3] | 14 | sout | "Starting"; |
[4cc9b13] | 15 | |
[cca568e] | 16 | when( false ) waitfor( notcalled : m ); |
[4cc9b13] | 17 | |
[200fcb3] | 18 | sout | "Step" | i++; |
[4cc9b13] | 19 | |
[cca568e] | 20 | waitfor( notcalled : m ); or else { |
[200fcb3] | 21 | sout | "else called"; |
[4cc9b13] | 22 | } |
23 | ||
[200fcb3] | 24 | sout | "Step" | i++; |
[4cc9b13] | 25 | |
[cca568e] | 26 | when( true ) waitfor( notcalled : m ); or when( true ) else { |
[200fcb3] | 27 | sout | "else called"; |
[4cc9b13] | 28 | } |
29 | ||
[200fcb3] | 30 | sout | "Step" | i++; |
[4cc9b13] | 31 | |
[cca568e] | 32 | when( false ) waitfor( notcalled : m ); or when( true ) else { |
[200fcb3] | 33 | sout | "else called"; |
[4cc9b13] | 34 | } |
35 | ||
[200fcb3] | 36 | sout | "Step" | i++; |
[4cc9b13] | 37 | |
[cca568e] | 38 | when( false ) waitfor( notcalled : m ); or when( false ) else { |
[200fcb3] | 39 | sout | "else called"; |
[4cc9b13] | 40 | } |
41 | ||
[200fcb3] | 42 | sout | "Done"; |
[4cc9b13] | 43 | } |
44 | ||
45 | int main() { | |
46 | M m; | |
47 | test(m); | |
[200fcb3] | 48 | } |
Note: See TracBrowser
for help on using the repository browser.