Changeset 9129a84 for src/examples


Ignore:
Timestamp:
Nov 28, 2016, 4:02:45 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
1f44196
Parents:
f773f67
Message:

Implemented suspend and resume for coroutines (CtxSw? does nothing)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/coroutine.c

    rf773f67 r9129a84  
    1212
    1313coroutine* this_coroutine(Fibonacci* this) {
    14 
     14      return &this->c;
    1515}
    1616
     
    1919      this->fn = 0;
    2020      fn1 = this->fn;
    21       suspend(this);            // return to last resume
     21      suspend();                // return to last resume
    2222
    2323      this->fn = 1;
    2424      fn2 = fn1;
    2525      fn1 = this->fn;
    26       suspend(this);            // return to last resume
     26      suspend();                // return to last resume
    2727
    2828      for ( ;; ) {
     
    3030            fn2 = fn1;
    3131            fn1 = this->fn;
    32             suspend(this);      // return to last resume
     32            suspend();  // return to last resume
    3333      }
    3434}
     
    3939}
    4040
    41 void main() {
     41int main() {
    4242      Fibonacci f1, f2;
    4343      for ( int i = 1; i <= 10; i += 1 ) {
    4444            sout | next(&f1) | ' ' | next(&f2) | endl;
    4545      }
     46
     47      return 0;
    4648}
Note: See TracChangeset for help on using the changeset viewer.