Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/concurrency/examples/Pingpong.cfa

    r1e5d0f0c r17c6c1c3  
    44coroutine PingPong {
    55        const char * name;
    6         unsigned int N;
    7         PingPong & part;
     6        /* const */ unsigned int N;
     7        PingPong * part;
    88};
    99
    1010void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) {
    11         this.[name, N] = [name, N];  &this.part = ∂
     11        (this.__cor){name};
     12        this.name = name;
     13        this.N = N;
     14        this.part = ∂
    1215}
    1316void ?{}( PingPong & this, const char * name, unsigned int N ) {
    14         this{ name, N, *0p };                                                           // call first constructor
     17        this{ name, N, *(PingPong *)0 };
    1518}
    1619void cycle( PingPong & pingpong ) {
     
    1821}
    1922void partner( PingPong & this, PingPong & part ) {
    20         &this.part = ∂
     23        this.part = ∂
    2124        resume( this );
    2225}
    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 );
     26void 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 );
    2730        } // for
    2831}
    2932int main() {
    30         enum { N = 5 };
     33        enum { N = 20 };
    3134        PingPong ping = { "ping", N }, pong = { "pong", N, ping };
    3235        partner( ping, pong );
     
    3538// Local Variables: //
    3639// tab-width: 4 //
    37 // compile-command: "cfa Pingpong.cfa" //
     40// compile-command: "cfa pingpong.cfa" //
    3841// End: //
Note: See TracChangeset for help on using the changeset viewer.