64,654
社区成员
发帖
与我相关
我的任务
分享
std::function<void(void)> dowork = nullptr;
while(true)
{
dosomething;//会改变以下if的条件
if (dowork != nullptr){
dowork();
}else{
if(...){dowork=[&](){ dosth; };continue;}
if(...){dowork=[&](){ dosth; };continue;}
if(...){dowork=[&](){ dosth; };continue;}
}
...
Sleep(5);
}
int s=0;
while (true)
{
dosomething;//会改变以下if的条件
switch (s) {
case 0:if(...){s=0;dosth;continue;}
case 1:if(...){s=1;dosth;continue;}
case 2:if(...){s=2;dosth;continue;}
...
}
Sleep(5);
}