- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm having some issues with deadlocks while running a tbb::task_group inside a tbb::parallel_for_each.
e.g.
[cpp]class worker_with_deadlock { result result_; tbb::task_group tasks_; public: ~worker_with_deadlock() { tasks_.cancel(); tasks_.wait(); } result run() { tasks_.wait(); auto my_result = std::move(result_); tasks_.run([=] { result_ = do_work(); }); return my_result; } } class worker_without_deadlock { result result_; public: result run() { auto my_result = std::move(result_); result_ = do_work(); return my_result; } } void run_workers() { // This will deadlock? tbb::parallel_for_each(workers.begin(), workers.end(), [&](worker_with_deadlock& worker) { result[worker.tag()] = worker.run(); }); // This will not deadlock? tbb::parallel_for_each(workers.begin(), workers.end(), [&](worker_without_deadlock& worker) { result[worker.tag()] = worker.run(); }); }[/cpp]
Unfortunately I do not have a code which you can use to reproduce the problem with at this moment.
Do you have any ideas as to what might cause this?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm afraid this code isn't very helpful to get an understanding of what you are trying to do...

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page