Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4566c85
Add task documentation to user guide
vossmjp Jul 25, 2025
4de1059
Added more details about task_group::wait thread safety
vossmjp Sep 12, 2025
d1d766d
Update doc/main/tbb_userguide/Parallelizing_with_Tasks.rst
vossmjp Sep 12, 2025
d3f8cd3
Fixed copyright
vossmjp Sep 12, 2025
f5b21a7
Update doc/main/tbb_userguide/examples/task_examples.cpp
vossmjp Sep 15, 2025
2f55a41
Update doc/main/tbb_userguide/examples/task_examples.cpp
vossmjp Sep 15, 2025
5a0f134
Addressed review comments
vossmjp Sep 15, 2025
c7ea938
Update doc/main/tbb_userguide/task_group_cancellation.rst
vossmjp Sep 16, 2025
a592315
Update doc/main/tbb_userguide/creating_tasks_with_task_group.rst
vossmjp Sep 16, 2025
668a17f
Update doc/main/tbb_userguide/task_group_thread_safety.rst
vossmjp Sep 16, 2025
bbc34f6
Update doc/main/tbb_userguide/task_group_thread_safety.rst
vossmjp Sep 16, 2025
0430818
Replaced CAS with comment
vossmjp Sep 16, 2025
335c02b
Simplified example
vossmjp Sep 19, 2025
634bba6
Modified other example to match simplification
vossmjp Sep 19, 2025
f33559a
Moved cancellation and shortened examples by ref
vossmjp Oct 3, 2025
f86c388
Update doc/main/tbb_userguide/examples/task_examples.cpp
vossmjp Oct 16, 2025
16a6423
Update doc/main/tbb_userguide/creating_tasks_with_task_group.rst
vossmjp Oct 16, 2025
b3f7578
Update doc/main/tbb_userguide/creating_tasks_with_task_group.rst
vossmjp Oct 16, 2025
030f7f0
Update doc/main/tbb_userguide/task_group_thread_safety.rst
vossmjp Oct 16, 2025
9ec8adc
Apply suggestion from @akukanov
vossmjp Oct 16, 2025
e1492fb
Updated cancellation to use task_group functions directly
vossmjp Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions doc/main/tbb_userguide/examples/task_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ void serial_tree_search(TreeNode* node, int target, TreeNode*& result) {
void sequential_tree_search(TreeNode* node, int target, std::atomic<TreeNode*>& result) {
if (node && !result.load()) {
if (node->value == target) {
TreeNode* expected = nullptr;
result.compare_exchange_strong(expected, node);
result.store(node); // overwrite is ok since any result is valid
} else {
sequential_tree_search(node->left, target, result);
sequential_tree_search(node->right, target, result);
Expand All @@ -74,8 +73,7 @@ void parallel_invoke_search(TreeNode* node, int target, std::atomic<TreeNode*>&
size_t depth_threshold = initial_depth_threshold) {
if (node && !result.load()) {
if (node->value == target) {
TreeNode* expected = nullptr;
result.compare_exchange_strong(expected, node);
result.store(node); // overwrite is ok since any result is valid
} else if (depth_threshold == 0) {
sequential_tree_search(node, target, result);
} else {
Expand All @@ -94,8 +92,7 @@ void parallel_tree_search_impl(tbb::task_group& tg, TreeNode* node, int target,
size_t depth_threshold = initial_depth_threshold) {
if (node && !result.load()) {
if (node->value == target) {
TreeNode* expected = nullptr;
result.compare_exchange_strong(expected, node);
result.store(node); // overwrite is ok since any result is valid
} else if (depth_threshold == 0) {
sequential_tree_search(node, target, result);
} else if (node->left) {
Expand Down Expand Up @@ -134,10 +131,8 @@ void parallel_tree_search_cancellable_impl(tbb::task_group& tg, TreeNode* node,
size_t depth_threshold = initial_depth_threshold) {
if (node && !ctx.is_group_execution_cancelled()) {
if (node->value == target) {
TreeNode* expected = nullptr;
if (result.compare_exchange_strong(expected, node)) {
ctx.cancel_group_execution();
}
result.store(node); // overwrite is ok since any result is valid
ctx.cancel_group_execution();
} else if (depth_threshold == 0) {
sequential_tree_search(node, target, result);
if (result.load() != nullptr) {
Expand Down