c++支撐coroutine的簡略示例。本站提示廣大學習愛好者:(c++支撐coroutine的簡略示例)文章只能為提供參考,不一定能成為您想要的結果。以下是c++支撐coroutine的簡略示例正文
平台:linux
依附:g++ supports c++0x
void func1()
{
coroutine.yield();
}
void func2(Coro_t co1)
{
coroutine.resume(co1);
coroutine.yield();
}
void func()
{
Coro_t co1 = coroutine.create(std::bind(&func1));
coroutine.resume(co1);
Coro_t co2 = coroutine.create(std::bind(&func2, co1));
coroutine.resume(co2);
coroutine.resume(co2);
}
int main()
{
Coro_t co = coroutine.create(std::bind(&func));
coroutine.resume(co);
return 0;
}