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 6545adff was             b8116cd, checked in by Thierry Delisle <tdelisle@…>, 8 years ago | 
        
          | 
Tested and fixed out-of-order waitfor of dtors
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            774 bytes | 
      
      
| Line |  | 
|---|
| 1 | //--------------------------------------------------------- | 
|---|
| 2 | // Barging test | 
|---|
| 3 | // Ensures the statement order is reverse when using waitfor ^?{} | 
|---|
| 4 | //--------------------------------------------------------- | 
|---|
| 5 |  | 
|---|
| 6 | #include <fstream> | 
|---|
| 7 | #include <kernel> | 
|---|
| 8 | #include <monitor> | 
|---|
| 9 | #include <stdlib> | 
|---|
| 10 | #include <thread> | 
|---|
| 11 |  | 
|---|
| 12 | #include <stdbool.h> | 
|---|
| 13 |  | 
|---|
| 14 | static const unsigned long N = 5_000ul; | 
|---|
| 15 |  | 
|---|
| 16 | thread dummy_t {}; | 
|---|
| 17 |  | 
|---|
| 18 | void ^?{}( dummy_t & mutex this ) { | 
|---|
| 19 | sout | "Dtor" | endl; | 
|---|
| 20 | } | 
|---|
| 21 |  | 
|---|
| 22 | void main( dummy_t & this ) { | 
|---|
| 23 | yield(((unsigned)rand48()) % 10); | 
|---|
| 24 | sout | "Main"; | 
|---|
| 25 | waitfor( ^?{}, this ) { | 
|---|
| 26 | sout | "After waitfor"; | 
|---|
| 27 | } | 
|---|
| 28 | sout | "Ending Main"; | 
|---|
| 29 | } | 
|---|
| 30 |  | 
|---|
| 31 | int main() { | 
|---|
| 32 | sout | "Starting" | endl; | 
|---|
| 33 | processor p; | 
|---|
| 34 | for( int i = 0; i < N; i++ ){ | 
|---|
| 35 | dummy_t dummy; | 
|---|
| 36 | yield( ((unsigned)rand48()) % 100 ); | 
|---|
| 37 | } | 
|---|
| 38 | sout | "Stopping" | endl; | 
|---|
| 39 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.