void TestPriorityAssertions () { #if TRY_BAD_EXPR_ENABLED && __TBB_TASK_PRIORITY REMARK( "TestPriorityAssertions\n" ); tbb::priority_t bad_low_priority = tbb::priority_t( tbb::priority_low - 1 ), bad_high_priority = tbb::priority_t( tbb::priority_high + 1 ); tbb::task_group_context ctx; // Catch assertion failures tbb::set_assertion_handler( AssertionFailureHandler ); TRY_BAD_EXPR( ctx.set_priority( bad_low_priority ), "Invalid priority level value" ); tbb::task &t = *new( tbb::task::allocate_root() ) tbb::empty_task; TRY_BAD_EXPR( tbb::task::enqueue( t, bad_high_priority ), "Invalid priority level value" ); // Restore normal assertion handling tbb::set_assertion_handler( ReportError ); #endif /* TRY_BAD_EXPR_ENABLED && __TBB_TASK_PRIORITY */ }
void operator()( int ) const { tbb::task_scheduler_init init; // Thread 1 attempts to incorrectly use the task created by thread 0. tbb::task_list list; // spawn_root_and_wait over empty list should vacuously succeed. tbb::task::spawn_root_and_wait(list); // Check that spawn_root_and_wait fails on non-empty list. list.push_back(*AbusedTask); // Try abusing recycle_as_continuation TRY_BAD_EXPR(AbusedTask->recycle_as_continuation(), "execute" ); TRY_BAD_EXPR(AbusedTask->recycle_as_safe_continuation(), "execute" ); TRY_BAD_EXPR(AbusedTask->recycle_to_reexecute(), "execute" ); ++AbuseOneTaskRan; }