#include #include #include #include // Start coroutine routines struct MyThread { thread t; unsigned id; unsigned count; }; DECL_THREAD(MyThread) void ?{}( MyThread * this ) { } void ?{}( MyThread * this, unsigned id, unsigned count ) { this->id = id; this->count = count; } void main(MyThread* this) { sout | "Thread" | this->id | " : Suspending" | this->count | "times" | endl; yield(); for(int i = 0; i < this->count; i++) { sout | "Thread" | this->id | " : Suspend No." | i + 1 | endl; yield(); } } int main(int argc, char* argv[]) { unsigned itterations = 10u; if(argc == 2) { int val = ato(argv[1]); assert(val >= 0); itterations = val; } sout | "User main begin" | endl; { processor p; { scoped(MyThread) thread1 = { 1u, itterations }; scoped(MyThread) thread2 = { 2u, itterations }; } } sout | "User main end" | endl; return 0; }