This action will force synchronization from Gitee 极速下载/cpp-taskflow, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
// Demonstrates the use of observer to monitor worker activities.#include <taskflow/taskflow.hpp>struct MyObserver : public tf::ObserverInterface {MyObserver(const std::string& name) {std::cout << "constructing observer " << name << '\n';}// set_up is a constructor-like method that will be called exactly once// passing the number of workersvoid set_up(size_t num_workers) override final {std::cout << "setting up observer with " << num_workers << " workers\n";}// on_entry will be called before a worker runs a taskvoid on_entry(tf::WorkerView wv, tf::TaskView tv) override final {std::ostringstream oss;oss << "worker " << wv.id() << " ready to run " << tv.name() << '\n';std::cout << oss.str();}// on_exit will be called after a worker completes a taskvoid on_exit(tf::WorkerView wv, tf::TaskView tv) override final {std::ostringstream oss;oss << "worker " << wv.id() << " finished running " << tv.name() << '\n';std::cout << oss.str();}};int main(){tf::Executor executor;// Create a taskflow of eight taskstf::Taskflow taskflow;taskflow.emplace([] () { std::cout << "1\n"; }).name("A");taskflow.emplace([] () { std::cout << "2\n"; }).name("B");taskflow.emplace([] () { std::cout << "3\n"; }).name("C");taskflow.emplace([] () { std::cout << "4\n"; }).name("D");taskflow.emplace([] () { std::cout << "5\n"; }).name("E");taskflow.emplace([] () { std::cout << "6\n"; }).name("F");taskflow.emplace([] () { std::cout << "7\n"; }).name("G");taskflow.emplace([] () { std::cout << "8\n"; }).name("H");// create a default observerstd::shared_ptr<MyObserver> observer = executor.make_observer<MyObserver>("MyObserver");// run the taskflowexecutor.run(taskflow).get();// remove the observer (optional)executor.remove_observer(std::move(observer));return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。