Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/waitfor/parse.cfa

    ra1b41e3 rcca568e  
    1 // 
    2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     1//----------------------------------------------------------------------------------------
     2//----------------------------------------------------------------------------------------
    33//
    4 // The contents of this file are covered under the licence agreement in the
    5 // file "LICENCE" distributed with Cforall.
    6 //
    7 // waitfor.c --
    8 //
    9 // Author           : Peter A. Buhr
    10 // Created On       : Wed Aug 30 17:53:29 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr 10 22:52:18 2023
    13 // Update Count     : 64
    14 //
     4//              DEPRECATED TEST
     5//              DIFFERS BETWEEN DEBUG AND RELEASE
     6//
     7//----------------------------------------------------------------------------------------
     8//----------------------------------------------------------------------------------------
    159
    1610#include <monitor.hfa>
     
    1812monitor M {};
    1913
    20 void notcalled( M & mutex m1, M & mutex m2 ) {
    21         abort();
    22 }
    23 void or( M & mutex m ) {
    24         abort();
    25 }
    26 void timeout( M & mutex m ) {
    27         abort();
     14M a;
     15
     16void f1( M & mutex a );
     17void f2( M & mutex a );
     18void f2( M & mutex a, M & mutex b );
     19void f3( M & mutex a );
     20void f3( M & mutex a, M & mutex b );
     21void f3( M & mutex a, M & mutex b, M & mutex c );
     22
     23void foo() {
     24
     25        //---------------------------------------
     26        waitfor( f1 : a ) {
     27                1;
     28        }
     29
     30        //---------------------------------------
     31        waitfor( f1 : a ) {
     32                2;
     33        }
     34        waitfor( f2 : a ) {
     35                3;
     36        }
     37
     38        //---------------------------------------
     39        when( 1 < 3 ) waitfor( f2 : a, a ) {
     40                4;
     41        }
     42        or timeout( 100 ) {
     43                5;
     44        }
     45
     46        //---------------------------------------
     47        when( 2 < 3 ) waitfor( f3 : a ) {
     48                5;
     49        }
     50        or else {
     51                6;
     52        }
     53
     54        //---------------------------------------
     55        when( 3 < 3 ) waitfor( f3 : a, a ) {
     56                7;
     57        }
     58        or when( 4 < 3 ) timeout( 101 ) {
     59                8;
     60        }
     61        or when( 5 < 3 ) else {
     62                9;
     63        }
     64
     65        //---------------------------------------
     66        when( 6 < 3 ) waitfor( f3 : a, a, a ) {
     67                10;
     68        }
     69        or when( 7 < 3 ) waitfor( f1 : a  ) {
     70                11;
     71        }
     72        or else {
     73                12;
     74        }
     75
     76        //---------------------------------------
     77        when( 8 < 3 ) waitfor( f3 : a, a ) {
     78                13;
     79        }
     80        or waitfor( f1 : a  ) {
     81                14;
     82        }
     83        or when( 9 < 3 ) timeout( 102 ) {
     84                15;
     85        }
     86
     87        //---------------------------------------
     88        when( 10 < 3 ) waitfor( f1 : a ) {
     89                16;
     90        }
     91        or waitfor( f2 : a, a ) {
     92                17;
     93        }
     94        or timeout( 103 ) {
     95                18;
     96        }
     97        or when( 11 < 3 ) else {
     98                19;
     99        }
    28100}
    29101
    30 void fred( M & mutex m, M & mutex or, M & mutex timeout ) {
    31         // test waitfor and when
    32 
    33         waitfor( notcalled : m, m );
    34 
    35         waitfor( notcalled : m, m ) {
    36         }
    37 
    38         waitfor( notcalled : m, m ) {
    39         }
    40 
    41         when( true ) waitfor( notcalled : m, m );
    42 
    43         when( true ) waitfor( notcalled : m, m ) {
    44         }
    45 
    46         waitfor( notcalled : m, m );
    47         or waitfor( notcalled : m, m );
    48 
    49         when( true ) waitfor( notcalled : m, m );
    50         or when( true ) waitfor( notcalled : m, m );
    51 
    52         waitfor( notcalled : m, m ) {
    53         } or waitfor( notcalled : m, m ) {
    54         }
    55 
    56         waitfor( notcalled : m, m ) {
    57         } or waitfor( notcalled : m, m ) {
    58         }
    59 
    60         when( true ) waitfor( notcalled : m, m ) {
    61         } or when( true ) waitfor( notcalled : m, m ) {
    62         }
    63 
    64         waitfor( notcalled : m, m );
    65         or waitfor( notcalled : m, m ) {
    66         }
    67 
    68         when( true ) waitfor( notcalled : m, m );
    69         or when( true ) waitfor( notcalled : m, m ) {
    70         }
    71 
    72         waitfor( notcalled : m, m ) {
    73         } or waitfor( notcalled : m, m );
    74 
    75         when( true ) waitfor( notcalled : m, m ) {
    76         } or when( true ) waitfor( notcalled : m, m );
    77 
    78         // test when, waitfor and else
    79 
    80         waitfor( notcalled : m, m );
    81         or else;
    82 
    83         when( true ) waitfor( notcalled : m, m );
    84         or else;
    85 
    86         when( true ) waitfor( notcalled : m, m );
    87         or else;
    88 
    89         waitfor( notcalled : m, m ) {
    90         } or else {
    91         }
    92 
    93         when( true ) waitfor( notcalled : m, m ) {
    94         } or else {
    95         }
    96 
    97         waitfor( notcalled : m, m );
    98         or else {
    99         }
    100 
    101         when( true ) waitfor( notcalled : m, m );
    102         or else {
    103         }
    104 
    105         when( true ) waitfor( notcalled : m, m );
    106         or else {
    107         }
    108 
    109         waitfor( notcalled : m, m ) {
    110         } or else;
    111 
    112         when( true ) waitfor( notcalled : m, m ) {
    113         } or else;
    114 
    115         waitfor( notcalled : m, m );
    116         or when( true ) else;
    117 
    118         when( true ) waitfor( notcalled : m, m );
    119         or when( true ) else;
    120 
    121         when( true ) waitfor( notcalled : m, m );
    122         or when( true ) else;
    123 
    124         waitfor( notcalled : m, m ) {
    125         } or when( true ) else {
    126         }
    127 
    128         when( true ) waitfor( notcalled : m, m ) {
    129         } or when( true ) else {
    130         }
    131 
    132         waitfor( notcalled : m, m );
    133         or when( true ) else {
    134         }
    135 
    136         when( true ) waitfor( notcalled : m, m );
    137         or when( true ) else {
    138         }
    139 
    140         when( true ) waitfor( notcalled : m, m );
    141         or when( true ) else {
    142         }
    143 
    144         waitfor( notcalled : m, m ) {
    145         } or when( true ) else;
    146 
    147         when( true ) waitfor( notcalled : m, m ) {
    148         } or when( true ) else;
    149 
    150         // test when, waitfor and timeout
    151 
    152         waitfor( notcalled : m, m );
    153         or timeout( 3 );
    154 
    155         waitfor( notcalled : m, m );
    156         or timeout( 3 );
    157 
    158         when( true ) waitfor( notcalled : m, m );
    159         or timeout( 3 );
    160 
    161         waitfor( notcalled : m, m ) {
    162         } or timeout( 3 ) {
    163         }
    164 
    165         when( true ) waitfor( notcalled : m, m ) {
    166         } or timeout( 3 ) {
    167         }
    168 
    169         when( true ) waitfor( notcalled : m, m ) {
    170         } or timeout( 3 ) {
    171         }
    172 
    173         when( true ) waitfor( notcalled : m, m ) {
    174         } or when ( true ) timeout( 3 ) {
    175         }
    176 
    177         when( true ) waitfor( notcalled : m, m ) {
    178         } or when ( true ) timeout( 3 ) {
    179         }
    180 
    181         waitfor( notcalled : m, m );
    182         or timeout( 3 ) {
    183         }
    184 
    185         when( true ) waitfor( notcalled : m, m );
    186         or timeout( 3 ) {
    187         }
    188 
    189         when( true ) waitfor( notcalled : m, m );
    190         or when( true ) timeout( 3 ) {
    191         }
    192 
    193         waitfor( notcalled : m, m ) {
    194         } or timeout( 3 );
    195 
    196         when( true ) waitfor( notcalled : m, m ) {
    197         } or timeout( 3 );
    198 
    199         when( true ) waitfor( notcalled : m, m ) {
    200         } or when( true ) timeout( 3 );
    201 
    202         // test when, waitfor, timeout and else
    203 
    204         waitfor( notcalled : m, m ) {
    205         } or timeout( 3 ) {
    206         } or when( true ) else {}
    207 
    208         when( true ) waitfor( notcalled : m, m ) {
    209         } or timeout( 3 ) {
    210         } or when( true ) else {}
    211 
    212         waitfor( notcalled : m, m ) {
    213         } or timeout( 3 ) {
    214         } or when( true ) else {}
    215 
    216         waitfor( notcalled : m, m ) {
    217         } or when( true ) timeout( 3 ) {
    218         } or when( true ) else {}
    219 
    220         when( true ) waitfor( notcalled : m, m ) {
    221         } or timeout( 3 ) {
    222         } or when( true ) else {}
    223 
    224         waitfor( notcalled : m, m ) {
    225         } or when( true ) timeout( 3 ) {
    226         } or when( true ) else {}
    227 
    228         when( true ) waitfor( notcalled : m, m ) {
    229         } or when( true ) timeout( 3 ) {
    230         } or when( true ) else {}
    231 
    232         // test quasi-keywords "or" and "timeout"
    233 
    234         int or = 0, timeout = 0;
    235         waitfor( timeout : timeout ) timeout += 1; or timeout( timeout );
    236         waitfor( notcalled : or, or ) or += 1; or timeout( or ) 3;
    237         when( or ) waitfor( or : m ) { 4; } or timeout( or ) or += 1;
    238         when( timeout ) waitfor( notcalled : timeout, timeout ) or += 1; or else timeout += 1;
    239         when( or + timeout ) waitfor( or : m ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout += 1;
    240         when( 3 ) waitfor( or : or ) 3; or when( or ) waitfor( notcalled : or, or ) 4; or else 4;
    241         when( timeout ) waitfor( or : timeout ) 3; or waitfor( notcalled : timeout, or ) 4; or when( or ) timeout( timeout ) 4;
    242         when( 3 ) waitfor( or : timeout ) or += 1;
    243         or waitfor( or : or ) timeout += 1;
    244         or timeout( timeout ) or += 1;
    245         or when( 3 ) else or += 1;
    246 
    247         // test else selection
    248 
    249         if ( or > timeout ) waitfor( or : or ) 3;
    250         else waitfor( timeout : timeout ) 4;
    251 }
    252 
    253 //Dummy main
    254 int main( int argc, char const * argv[] ) {
    255     #pragma GCC warning "Compiled"                      // force non-empty .expect file, NO TABS!!!
    256 }
    257 
    258 // Local Variables: //
    259 // tab-width: 4 //
    260 // compile-command: "cfa waitfor.cfa" //
    261 // End: //
     102int main() {}
Note: See TracChangeset for help on using the changeset viewer.