ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 8a30423 was
17c6c1c3,
checked in by Peter A. Buhr <pabuhr@…>, 6 years ago
|
add more paper examples
|
-
Property mode set to
100644
|
File size:
955 bytes
|
Rev | Line | |
---|
[17c6c1c3] | 1 | #include <coroutine.hfa> |
---|
| 2 | #include <fstream.hfa> |
---|
| 3 | |
---|
| 4 | coroutine PingPong { |
---|
| 5 | const char * name; |
---|
| 6 | /* const */ unsigned int N; |
---|
| 7 | PingPong * part; |
---|
| 8 | }; |
---|
| 9 | |
---|
| 10 | void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) { |
---|
| 11 | (this.__cor){name}; |
---|
| 12 | this.name = name; |
---|
| 13 | this.N = N; |
---|
| 14 | this.part = ∂ |
---|
| 15 | } |
---|
| 16 | void ?{}( PingPong & this, const char * name, unsigned int N ) { |
---|
| 17 | this{ name, N, *(PingPong *)0 }; |
---|
| 18 | } |
---|
| 19 | void cycle( PingPong & pingpong ) { |
---|
| 20 | resume( pingpong ); |
---|
| 21 | } |
---|
| 22 | void partner( PingPong & this, PingPong & part ) { |
---|
| 23 | this.part = ∂ |
---|
| 24 | resume( this ); |
---|
| 25 | } |
---|
| 26 | void main( PingPong & pingpong ) { // ping's starter ::main, pong's starter ping |
---|
| 27 | for ( pingpong.N ) { // N ping-pongs |
---|
| 28 | sout | pingpong.name; |
---|
| 29 | cycle( *pingpong.part ); |
---|
| 30 | } // for |
---|
| 31 | } |
---|
| 32 | int main() { |
---|
| 33 | enum { N = 20 }; |
---|
| 34 | PingPong ping = { "ping", N }, pong = { "pong", N, ping }; |
---|
| 35 | partner( ping, pong ); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | // Local Variables: // |
---|
| 39 | // tab-width: 4 // |
---|
| 40 | // compile-command: "cfa pingpong.cfa" // |
---|
| 41 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.