void OtherBusiness1() { if (i <= 0) { i++; std::cout << "use coroutine---start000" << std::endl; start_coroutine(&mainCoro); std::cout << "use coroutine---end0000" << std::endl; std::cout << "use coroutine---start111" << std::endl; start_coroutine(&mainCoro); std::cout << "use coroutine---end111" << std::endl; std::cout << "use coroutine---start222" << std::endl; start_coroutine(&mainCoro); std::cout << "use coroutine---end222" << std::endl; } printf("do others business1111111\n"); }
test_coroutine () { struct coroutine cr; jmp_buf calling, env; #define STACK_SIZE 1000 int stack [STACK_SIZE]; int x; char *str; int y; cr.calling = &calling; cr.env = &env; str = "Parametre lancement"; y = (int)str; x = start_coroutine (&cr, coroutine1, y /*(int)"Parametre lancement"*/, stack + STACK_SIZE); printf ("Lancement retourne <%s>\n", x+BASE); x = call_coroutine (&cr, (int)"1er appel"); printf ("1er appel retourne <%s>\n", x+BASE); x = call_coroutine (&cr, (int)"2eme appel"); printf ("2eme appel retourne <%s>\n", x+BASE); }