Changeset 86fb8f2 for doc/papers/concurrency/examples/Pingpong.cfa
- Timestamp:
- Mar 27, 2019, 11:09:23 AM (3 years ago)
- Branches:
- arm-eh, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
- Children:
- a45fc7b
- Parents:
- 2b10f95 (diff), 1e5d0f0c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/examples/Pingpong.cfa
r2b10f95 r86fb8f2 4 4 coroutine PingPong { 5 5 const char * name; 6 /* const */unsigned int N;7 PingPong *part;6 unsigned int N; 7 PingPong & part; 8 8 }; 9 9 10 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 = ∂ 11 this.[name, N] = [name, N]; &this.part = ∂ 15 12 } 16 13 void ?{}( PingPong & this, const char * name, unsigned int N ) { 17 this{ name, N, * (PingPong *)0 };14 this{ name, N, *0p }; // call first constructor 18 15 } 19 16 void cycle( PingPong & pingpong ) { … … 21 18 } 22 19 void partner( PingPong & this, PingPong & part ) { 23 this.part = ∂20 &this.part = ∂ 24 21 resume( this ); 25 22 } 26 void main( PingPong & pingpong ) {// ping's starter ::main, pong's starter ping27 for ( pingpong.N ) {// N ping-pongs28 sout | pingpong.name;29 cycle( *pingpong.part );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 ); 30 27 } // for 31 28 } 32 29 int main() { 33 enum { N = 20};30 enum { N = 5 }; 34 31 PingPong ping = { "ping", N }, pong = { "pong", N, ping }; 35 32 partner( ping, pong ); … … 38 35 // Local Variables: // 39 36 // tab-width: 4 // 40 // compile-command: "cfa pingpong.cfa" //37 // compile-command: "cfa Pingpong.cfa" // 41 38 // End: //
Note: See TracChangeset
for help on using the changeset viewer.