ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        resolv-new
        with_gc
      
      
        
          | 
            Last change
 on this file since fc72845d was             4cc9b13, checked in by Thierry Delisle <tdelisle@…>, 8 years ago           | 
        
        
          | 
             
Added waitfor test for else clauses and fixed corresponding errors 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            770 bytes
           | 
        
      
      
| Rev | Line |   | 
|---|
| [4cc9b13] | 1 | #include <fstream>
 | 
|---|
 | 2 | #include <monitor>
 | 
|---|
 | 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;
 | 
|---|
 | 14 |         sout | "Starting" | endl;
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 |         when( false ) waitfor( notcalled, m );
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 |         sout | "Step" | i++ | endl;
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 |         waitfor( notcalled, m ); or else {
 | 
|---|
 | 21 |                 sout | "else called" | endl;
 | 
|---|
 | 22 |         }
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 |         sout | "Step" | i++ | endl;
 | 
|---|
 | 25 | 
 | 
|---|
 | 26 |         when( true ) waitfor( notcalled, m ); or when( true ) else {
 | 
|---|
 | 27 |                 sout | "else called" | endl;
 | 
|---|
 | 28 |         }
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 |         sout | "Step" | i++ | endl;
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 |         when( false ) waitfor( notcalled, m ); or when( true ) else {
 | 
|---|
 | 33 |                 sout | "else called" | endl;
 | 
|---|
 | 34 |         }
 | 
|---|
 | 35 | 
 | 
|---|
 | 36 |         sout | "Step" | i++ | endl;
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 |         when( false ) waitfor( notcalled, m ); or when( false ) else {
 | 
|---|
 | 39 |                 sout | "else called" | endl;
 | 
|---|
 | 40 |         }
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 |         sout | "Done" | endl;
 | 
|---|
 | 43 | }
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | int main() {
 | 
|---|
 | 46 |         M m;
 | 
|---|
 | 47 |         test(m);
 | 
|---|
 | 48 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.