Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion include/oneapi/tbb/task_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace {
task_handle th = std::forward<F>(f)();
task_handle_task* task_ptr = task_handle_accessor::release(th);
// If task has unresolved dependencies, it can't be bypassed
if (task_ptr->has_dependencies() && !task_ptr->release_dependency()) {
if (task_ptr && task_ptr->has_dependencies() && !task_ptr->release_dependency()) {
task_ptr = nullptr;
}

Expand Down
17 changes: 17 additions & 0 deletions test/tbb/test_task_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,16 @@ TEST_CASE("Task handle for scheduler bypass"){

tg.wait();
CHECK_MESSAGE(run == true, "task handle returned by user lambda (bypassed) should be run");

// Test returning an empty handle
run = false;
tg.run([&] {
run = true;
return tbb::task_handle{};
});

tg.wait();
CHECK(run == true);
}

//! The test for task_handle inside other task waiting with run_and_wait
Expand All @@ -1187,6 +1197,13 @@ TEST_CASE("Task handle for scheduler bypass via run_and_wait"){
});

CHECK_MESSAGE(run == true, "task handle returned by user lambda (bypassed) should be run");

// Test returning an empty handle
run = false;
tg.run_and_wait([&] {
run = true;
});
CHECK(run == true);
}
#endif //__TBB_PREVIEW_TASK_GROUP_EXTENSIONS

Expand Down