ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resnenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change
on this file since 90cfc16 was
ae4af81,
checked in by Peter A. Buhr <pabuhr@…>, 6 years ago
|
more forctrl changes
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[73abe95] | 1 | // |
---|
[9bae71f] | 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. |
---|
[73abe95] | 6 | // |
---|
| 7 | // pingpong.c -- |
---|
| 8 | // |
---|
[9bae71f] | 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Wed Sep 20 11:55:23 2017 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[ae4af81] | 12 | // Last Modified On : Sat Aug 18 11:31:11 2018 |
---|
| 13 | // Update Count : 28 |
---|
[73abe95] | 14 | // |
---|
[9bae71f] | 15 | |
---|
[73abe95] | 16 | #include <coroutine.hfa> |
---|
| 17 | #include <fstream.hfa> |
---|
[9bae71f] | 18 | |
---|
| 19 | coroutine PingPong { |
---|
| 20 | const char * name; |
---|
| 21 | /* const */ unsigned int N; |
---|
| 22 | PingPong * part; |
---|
| 23 | }; |
---|
| 24 | |
---|
| 25 | void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) { |
---|
| 26 | this.name = name; |
---|
| 27 | this.N = N; |
---|
| 28 | this.part = ∂ |
---|
| 29 | } |
---|
| 30 | void ?{}( PingPong & this, const char * name, unsigned int N ) { |
---|
| 31 | this{ name, N, *(PingPong *)0 }; |
---|
| 32 | } |
---|
| 33 | void cycle( PingPong & pingpong ) { |
---|
| 34 | resume( pingpong ); |
---|
| 35 | } |
---|
| 36 | void partner( PingPong & this, PingPong & part ) { |
---|
| 37 | this.part = ∂ |
---|
| 38 | resume( this ); |
---|
| 39 | } |
---|
| 40 | void main( PingPong & pingpong ) { // ping's starter ::main, pong's starter ping |
---|
[ae4af81] | 41 | for ( pingpong.N ) { // N ping-pongs |
---|
[9bae71f] | 42 | sout | pingpong.name | endl; |
---|
| 43 | cycle( *pingpong.part ); |
---|
| 44 | } // for |
---|
| 45 | } |
---|
| 46 | int main() { |
---|
| 47 | enum { N = 20 }; |
---|
| 48 | PingPong ping = { "ping", N }, pong = { "pong", N, ping }; |
---|
| 49 | partner( ping, pong ); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | // Local Variables: // |
---|
| 53 | // tab-width: 4 // |
---|
| 54 | // compile-command: "cfa pingpong.c" // |
---|
| 55 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.