1 Star 0 Fork 37

uxsys/cpp-taskflow

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
do_while_loop.cpp 686 Bytes
一键复制 编辑 原始数据 按行查看 历史
alexbriskin 提交于 2022-03-22 04:24 +08:00 . Remove trailing whitespace (#386)
// This program demonstrates how to implement do-while control flow
// using condition tasks.
#include <taskflow/taskflow.hpp>
int main() {
tf::Executor executor;
tf::Taskflow taskflow;
int i;
auto [init, body, cond, done] = taskflow.emplace(
[&](){ std::cout << "i=0\n"; i=0; },
[&](){ std::cout << "i++ => i="; i++; },
[&](){ std::cout << i << '\n'; return i<5 ? 0 : 1; },
[&](){ std::cout << "done\n"; }
);
init.name("init");
body.name("do i++");
cond.name("while i<5");
done.name("done");
init.precede(body);
body.precede(cond);
cond.precede(body, done);
//taskflow.dump(std::cout);
executor.run(taskflow).wait();
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/uxsys/cpp-taskflow.git
git@gitee.com:uxsys/cpp-taskflow.git
uxsys
cpp-taskflow
cpp-taskflow
master

搜索帮助