1 Star 0 Fork 37

李鑫哲/cpp-taskflow

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
runtime.cpp 821 Bytes
一键复制 编辑 原始数据 按行查看 历史
alexbriskin 提交于 2022-03-22 04:24 +08:00 . Remove trailing whitespace (#386)
// This program demonstrates how to use a runtime task to forcefully
// schedule an active task that would never be scheduled.
#include <taskflow/taskflow.hpp>
int main() {
tf::Taskflow taskflow("Runtime Tasking");
tf::Executor executor;
tf::Task A, B, C, D;
std::tie(A, B, C, D) = taskflow.emplace(
[] () { return 0; },
[&C] (tf::Runtime& rt) { // C must be captured by reference
std::cout << "B\n";
rt.schedule(C);
},
[] () { std::cout << "C\n"; },
[] () { std::cout << "D\n"; }
);
// name tasks
A.name("A");
B.name("B");
C.name("C");
D.name("D");
// create conditional dependencies
A.precede(B, C, D);
// dump the graph structure
taskflow.dump(std::cout);
// we will see both B and C in the output
executor.run(taskflow).wait();
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/li_xinCode/cpp-taskflow.git
git@gitee.com:li_xinCode/cpp-taskflow.git
li_xinCode
cpp-taskflow
cpp-taskflow
master

搜索帮助