Ignore:
Timestamp:
May 18, 2018, 2:09:21 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
2472a19
Parents:
f6f0cca3 (diff), c7d8100c (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.
Message:

Merge remote-tracking branch 'origin/master' into with_gc

Location:
src/tests/coroutine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tests/coroutine/fibonacci.c

    rf6f0cca3 rff29f08  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fibonacci.c --
     7// fibonacci.c -- 3-state finite-state machine
     8
    89//
    910// Author           : Thierry Delisle
    1011// Created On       : Thu Jun  8 07:29:37 2017
    1112// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 22 22:45:44 2018
    13 // Update Count     : 15
     13// Last Modified On : Fri Apr 27 08:55:31 2018
     14// Update Count     : 19
    1415//
    1516
     
    1920coroutine Fibonacci { int fn; };                                                // used for communication
    2021
    21 void ?{}( Fibonacci & fib ) with( fib ) { fn = 0; }
    22 
    23 // main automatically called on first resume
    24 void main( Fibonacci & fib ) with( fib ) {
     22void main( Fibonacci & fib ) with( fib ) {                              // called on first resume
    2523        int fn1, fn2;                                                                           // retained between resumes
    2624        fn = 0;  fn1 = fn;                                                                      // 1st case
     
    2927        suspend();                                                                                      // restart last resume
    3028        for ( ;; ) {
    31                 fn = fn1 + fn2; fn2 = fn1;  fn1 = fn;                   // general case
     29                fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;                  // general case
    3230                suspend();                                                                              // restart last resume
    3331        } // for
  • src/tests/coroutine/fmtLines.c

    rf6f0cca3 rff29f08  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fmtLines.cc --
     7// fmtLines.cc -- format characters into blocks of 4 and groups of 5 blocks per line
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  5 21:56:35 2017
    13 // Update Count     : 38
     12// Last Modified On : Tue May 15 12:25:33 2018
     13// Update Count     : 42
    1414//
    1515
     
    2121        int g, b;                                                                                       // global because used in destructor
    2222};
    23 
    24 void ?{}( Format & fmt ) {
    25         resume( fmt );                                                                          // prime (start) coroutine
    26 }
    27 
    28 void ^?{}( Format & fmt ) with( fmt ) {
    29         if ( g != 0 || b != 0 ) sout | endl;
    30 }
    3123
    3224void main( Format & fmt ) with( fmt ) {
     
    4638} // main
    4739
    48 void prt( Format & fmt, char ch ) {
    49         fmt.ch = ch;
     40void ?{}( Format & fmt ) {
     41        resume( fmt );                                                                          // prime (start) coroutine
     42}
     43
     44void ^?{}( Format & fmt ) with( fmt ) {
     45        if ( g != 0 || b != 0 ) sout | endl;
     46}
     47
     48void format( Format & fmt ) {
    5049        resume( fmt );
    5150} // prt
    5251
    5352int main() {
    54         Format fmt;                                                                                     // format characters into blocks of 4 and groups of 5 blocks per line
    55         char ch;
     53        Format fmt;
    5654
    57         Eof: for ( ;; ) {                                                                       // read until end of file
    58                 sin | ch;                                                                               // read one character
    59           if ( eof( sin ) ) break Eof;                                          // eof ?
    60                 prt( fmt, ch );                                                                 // push character for formatting
     55        eof: for ( ;; ) {                                                                       // read until end of file
     56                sin | fmt.ch;                                                                   // read one character
     57          if ( eof( sin ) ) break eof;                                          // eof ?
     58                format( fmt );                                                                  // push character for formatting
    6159        } // for
    6260} // main
Note: See TracChangeset for help on using the changeset viewer.