同步操作将从 Gitee 极速下载/cpp-taskflow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// This program demonstrates how to set priority to a task.//// Currently, Taskflow supports only three priority levels:// + tf::TaskPriority::HIGH (numerical value = 0)// + tf::TaskPriority::NORMAL (numerical value = 1)// + tf::TaskPriority::LOW (numerical value = 2)//// Priority-based execution is non-preemptive. Once a task// has started to execute, it will execute to completion,// even if a higher priority task has been spawned or enqueued.#include <taskflow/taskflow.hpp>int main() {// create an executor of only one worker to enable// deterministic behaviortf::Executor executor(1);tf::Taskflow taskflow;int counter {0};// Here we create five tasks and print thier execution// orders which should align with assigned prioritiesauto [A, B, C, D, E] = taskflow.emplace([] () { },[&] () {std::cout << "Task B: " << counter++ << '\n'; // 0},[&] () {std::cout << "Task C: " << counter++ << '\n'; // 2},[&] () {std::cout << "Task D: " << counter++ << '\n'; // 1},[] () { });A.precede(B, C, D);E.succeed(B, C, D);// By default, all tasks are of tf::TaskPriority::HIGHB.priority(tf::TaskPriority::HIGH);C.priority(tf::TaskPriority::LOW);D.priority(tf::TaskPriority::NORMAL);assert(B.priority() == tf::TaskPriority::HIGH);assert(C.priority() == tf::TaskPriority::LOW);assert(D.priority() == tf::TaskPriority::NORMAL);// we should see B, D, and C in their priority orderexecutor.run(taskflow).wait();}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。