| Last change
 on this file since cad8c88 was             7bef8cf, checked in by Peter A. Buhr <pabuhr@…>, 2 years ago | 
        
          | 
start paper on llheap
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            946 bytes | 
      
      
| Rev | Line |  | 
|---|
| [7bef8cf] | 1 | #include <coroutine.hfa> | 
|---|
|  | 2 | #include <fstream.hfa> | 
|---|
|  | 3 |  | 
|---|
|  | 4 | coroutine PingPong { | 
|---|
|  | 5 | const char * name; | 
|---|
|  | 6 | unsigned int N; | 
|---|
|  | 7 | PingPong & part; | 
|---|
|  | 8 | }; | 
|---|
|  | 9 |  | 
|---|
|  | 10 | // void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) { | 
|---|
|  | 11 | //      this.[name, N] = [name, N];  &this.part = ∂ | 
|---|
|  | 12 | // } | 
|---|
|  | 13 | // void ?{}( PingPong & this, const char * name, unsigned int N ) { | 
|---|
|  | 14 | //      this{ name, N, *0p };                                                           // call first constructor | 
|---|
|  | 15 | // } | 
|---|
|  | 16 | void cycle( PingPong & pingpong ) { | 
|---|
|  | 17 | resume( pingpong ); | 
|---|
|  | 18 | } | 
|---|
|  | 19 | void partner( PingPong & this, PingPong & part ) { | 
|---|
|  | 20 | &this.part = ∂ | 
|---|
|  | 21 | resume( this ); | 
|---|
|  | 22 | } | 
|---|
|  | 23 | void main( PingPong & pingpong ) with(pingpong) {               // ping's starter ::main, pong's starter ping | 
|---|
|  | 24 | for ( N ) {                                                                                     // N ping-pongs | 
|---|
|  | 25 | sout | name; | 
|---|
|  | 26 | cycle( part ); | 
|---|
|  | 27 | } // for | 
|---|
|  | 28 | } | 
|---|
|  | 29 | int main() { | 
|---|
|  | 30 | enum { N = 5 }; | 
|---|
|  | 31 | PingPong ping = { "ping", N }, pong = { "pong", N, ping }; | 
|---|
|  | 32 | partner( ping, pong ); | 
|---|
|  | 33 | } | 
|---|
|  | 34 |  | 
|---|
|  | 35 | // Local Variables: // | 
|---|
|  | 36 | // tab-width: 4 // | 
|---|
|  | 37 | // compile-command: "cfa Pingpong.cfa" // | 
|---|
|  | 38 | // End: // | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.