未验证 提交 4fbacf34 编写于 作者: A Aleksei Fedotov 提交者: GitHub

Merge pull request #368 from anton-potapov/task_group_extensions_fixup

Fixup for POC: Extend tbb::task_group to support new use cases
......@@ -439,7 +439,6 @@ inline int current_thread_index() {
return idx == -1 ? task_arena_base::not_initialized : idx;
}
//! Returns the index, aka slot number, of the calling thread in its current arena
inline bool is_inside_task() {
return nullptr != current_context();
}
......
......@@ -338,7 +338,7 @@ class function_task : public task {
const F m_func;
wait_context& m_wait_ctx;
small_object_allocator m_allocator;
public:
void finalize(const execution_data& ed) {
// Make a local reference not to access this after destruction.
wait_context& wo = m_wait_ctx;
......@@ -500,7 +500,7 @@ public:
spawn(*prepare_task(std::forward<F>(f)), *m_context);
}
void run(task_handle& h) {
void run(task_handle&& h) {
task* t = h.release();
__TBB_ASSERT(t, "Attempt running empty task_handle.");
__TBB_ASSERT(m_context, nullptr);
......
......@@ -1003,7 +1003,7 @@ TEST_CASE("Task handle run"){
run = true;
});
ASSERT(run == false, "delayed task should not be run until run(task_handle) is called");
tg.run(h);
tg.run(std::move(h));
tg.wait();
ASSERT(run == true, "Delayed task should be completed when task_group::wait exits");
}
......@@ -1044,7 +1044,7 @@ TEST_CASE("Task handle blocks wait"){
utils::SpinWaitUntilEq(thread_started, true);
ASSERT(completed == false, "Deferred task should not be run until run(task_handle) is called");
tg.run(h);
tg.run(std::move(h));
//TODO: more accurate test (with fixed number of threads (1 ?) to guarantee correctness of following assert)
//ASSERT(completed == false, "Deferred task should not be run until run(task_handle) and wait is called");
start_wait = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册