Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/coroutine/suspend_then.cfa

    rdfa4360 r5b11c25  
    1515
    1616#include <fstream.hfa>
     17#include <coroutine.hfa>
    1718
    18 generator Fibonacci {
    19         int fn;                                                                         // used for communication
    20         int fn1, fn2;                                                           // retained between resumes
    21 };
     19void then() {
     20        sout | "Then!";
     21}
     22
     23coroutine Fibonacci { int fn; };                                                // used for communication
    2224
    2325void main( Fibonacci & fib ) with( fib ) {                              // called on first resume
     26        int fn1, fn2;                                                           // retained between resumes
    2427        fn = 0;  fn1 = fn;                                                      // 1st case
    25         suspend { sout | "Then!"; }                                             // restart last resume
     28        suspend_then(then);                                                     // restart last resume
    2629        fn = 1;  fn2 = fn1;  fn1 = fn;                                  // 2nd case
    27         suspend { sout | "Then!"; }                                             // restart last resume
     30        suspend_then(then);                                                     // restart last resume
    2831        for () {
    2932                fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;                  // general case
    30                 suspend { sout | "Then!"; }                                     // restart last resume
     33                suspend_then(then);                                             // restart last resume
    3134        } // for
    3235}
Note: See TracChangeset for help on using the changeset viewer.