ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | Last change
 on this file since 39fc03e was             427854b, checked in by Thierry Delisle <tdelisle@…>, 6 years ago | 
        
          | 
First draft implementation of generators, still missing error checking, testing and clean-up
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.0 KB | 
      
      
| Line |  | 
|---|
| 1 | // | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo | 
|---|
| 3 | // | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
| 5 | // file "LICENCE" distributed with Cforall. | 
|---|
| 6 | // | 
|---|
| 7 | // raii.cfa -- | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Thierry Delisle | 
|---|
| 10 | // Created On       : Mon May 27 13:39:58 2019 | 
|---|
| 11 | // Last Modified By : | 
|---|
| 12 | // Last Modified On : | 
|---|
| 13 | // Update Count     : | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #include <fstream.hfa> | 
|---|
| 17 | #include <coroutine.hfa> | 
|---|
| 18 |  | 
|---|
| 19 | struct Raii { | 
|---|
| 20 | const char * name; | 
|---|
| 21 | }; | 
|---|
| 22 |  | 
|---|
| 23 | void ?{}( Raii & this, const char * name ) { | 
|---|
| 24 | this.name = name; | 
|---|
| 25 | sout | "Raii Ctor" | this.name; | 
|---|
| 26 | } | 
|---|
| 27 |  | 
|---|
| 28 | void ^?{}( Raii & this ) { | 
|---|
| 29 | sout | "Raii Dtor" | this.name; | 
|---|
| 30 | } | 
|---|
| 31 |  | 
|---|
| 32 | coroutine Cor {}; | 
|---|
| 33 |  | 
|---|
| 34 | void ?{}( Cor & this ) { | 
|---|
| 35 | sout | "Coroutine Ctor"; | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | void main( Cor & this ) { | 
|---|
| 39 | Raii raii = { "Coroutine" }; | 
|---|
| 40 | sout | "Before Suspend"; | 
|---|
| 41 | suspend; | 
|---|
| 42 | sout | "After Suspend"; | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 | void ^?{}( Cor & this ) { | 
|---|
| 46 | sout | "Coroutine Dtor"; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | int main() { | 
|---|
| 50 | Raii raii = { "Main" }; | 
|---|
| 51 | Cor cor; | 
|---|
| 52 | resume(cor); | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | // Local Variables: // | 
|---|
| 56 | // tab-width: 4 // | 
|---|
| 57 | // compile-command: "cfa -g -Wall -Wextra raii.cfa" // | 
|---|
| 58 | // End: // | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.