ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 201aeb9 was
9f5ecf5,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
Skeleton for waitfor language support
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[9f5ecf5] | 1 | #include <monitor> |
---|
| 2 | |
---|
| 3 | monitor M {}; |
---|
| 4 | |
---|
| 5 | M a; |
---|
| 6 | |
---|
| 7 | void f1( M & mutex a ); |
---|
| 8 | void f2( M & mutex a ); |
---|
| 9 | void f2( M & mutex a, M & mutex b ); |
---|
| 10 | void f3( M & mutex a ); |
---|
| 11 | void f3( M & mutex a, M & mutex b ); |
---|
| 12 | void f3( M & mutex a, M & mutex b, M & mutex c ); |
---|
| 13 | |
---|
| 14 | void foo() { |
---|
| 15 | |
---|
| 16 | //--------------------------------------- |
---|
| 17 | waitfor( f1, a ) { |
---|
| 18 | 1; |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | //--------------------------------------- |
---|
| 22 | waitfor( f1, a ) { |
---|
| 23 | 2; |
---|
| 24 | } |
---|
| 25 | waitfor( f2, a ) { |
---|
| 26 | 3; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | //--------------------------------------- |
---|
| 30 | when( 1 < 3 ) waitfor( f2, a, a ) { |
---|
| 31 | 4; |
---|
| 32 | } |
---|
| 33 | or timeout( 100 ) { |
---|
| 34 | 5; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | //--------------------------------------- |
---|
| 38 | when( 2 < 3 ) waitfor( f3, a ) { |
---|
| 39 | 5; |
---|
| 40 | } |
---|
| 41 | or else { |
---|
| 42 | 6; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | //--------------------------------------- |
---|
| 46 | when( 3 < 3 ) waitfor( f3, a, a ) { |
---|
| 47 | 7; |
---|
| 48 | } |
---|
| 49 | or when( 4 < 3 ) timeout( 101 ) { |
---|
| 50 | 8; |
---|
| 51 | } |
---|
| 52 | or when( 5 < 3 ) else { |
---|
| 53 | 9; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | //--------------------------------------- |
---|
| 57 | when( 6 < 3 ) waitfor( f3, a, a, a ) { |
---|
| 58 | 10; |
---|
| 59 | } |
---|
| 60 | or when( 7 < 3 ) waitfor( f1, a ) { |
---|
| 61 | 11; |
---|
| 62 | } |
---|
| 63 | or else { |
---|
| 64 | 12; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | //--------------------------------------- |
---|
| 68 | when( 8 < 3 ) waitfor( f3, a, a ) { |
---|
| 69 | 13; |
---|
| 70 | } |
---|
| 71 | or waitfor( f1, a ) { |
---|
| 72 | 14; |
---|
| 73 | } |
---|
| 74 | or when( 9 < 3 ) timeout( 102 ) { |
---|
| 75 | 15; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | //--------------------------------------- |
---|
| 79 | when( 10 < 3 ) waitfor( f1, a ) { |
---|
| 80 | 16; |
---|
| 81 | } |
---|
| 82 | or waitfor( f1, a, a ) { |
---|
| 83 | 17; |
---|
| 84 | } |
---|
| 85 | or timeout( 103 ) { |
---|
| 86 | 18; |
---|
| 87 | } |
---|
| 88 | or when( 11 < 3 ) else { |
---|
| 89 | 19; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | int main() { |
---|
| 94 | |
---|
| 95 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.