- Timestamp:
- Mar 21, 2017, 12:36:01 PM (8 years ago)
- 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:
- 168c007, cb0e6de
- Parents:
- 31ce3d6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/tests/coroutine.c ¶
r31ce3d6 re04b636 2 2 #include <coroutine> 3 3 4 structFibonacci {4 coroutine Fibonacci { 5 5 int fn; // used for communication 6 coroutine_desc __cor;7 6 }; 8 7 … … 11 10 } 12 11 13 coroutine_desc* get_coroutine(Fibonacci* this) {14 return &this->__cor;15 }16 17 12 void main(Fibonacci* this) { 18 #ifdef MORE_DEBUG19 sout | "Starting main of coroutine " | this | endl;20 sout | "Started from " | this->__cor.last | endl;21 #endif22 13 int fn1, fn2; // retained between resumes 23 14 this->fn = 0; … … 45 36 int main() { 46 37 Fibonacci f1, f2; 47 #ifdef MORE_DEBUG48 Fibonacci *pf1 = &f1, *pf2 = &f2;49 coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c;50 covptr_t *vf1 = vtable(pf1), *vf2 = vtable(pf2);51 coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);52 Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2);53 54 sout | "User coroutines : " | pf1 | ' ' | pf2 | endl;55 sout | "Coroutine data : " | cf1 | ' ' | cf2 | endl;56 sout | "Vptr address : " | vf1 | ' ' | vf2 | endl;57 sout | "Vptr obj data : " | ov1 | ' ' | ov2 | endl;58 sout | "Vptr cor data : " | cv1 | ' ' | cv2 | endl;59 #endif60 38 for ( int i = 1; i <= 10; i += 1 ) { 61 39 sout | next(&f1) | ' ' | next(&f2) | endl;
Note: See TracChangeset
for help on using the changeset viewer.