void a_body(coroutine_type::self& self, int arg) { std::cout << "A(" << arg << ")" << std::endl; BOOST_CHECK_EQUAL(arg, 10); arg = self.yield_to(coro_b, arg+=1); std::cout << "A(" << arg << ")" << std::endl; BOOST_CHECK_EQUAL(arg, 20); arg = self.yield_to(coro_b, arg+=1); std::cout << "A(" << arg << ")" << std::endl; BOOST_CHECK_EQUAL(arg, 22); arg = self.yield(); BOOST_FAIL("Coroutine-A reached the end of the function"); }
my_result coro(coroutine_type& other, int id, coroutine_type::self& self, my_parm parm) { int i = 10; my_result t; while(--i) { std::cout<<"in coroutine "<<id<<"\n"; parm = self.yield_to(other, parm); } return t; }