Skip to content

Commit

Permalink
Clarification.
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Zientkiewicz <[email protected]>
  • Loading branch information
mzient committed Apr 19, 2024
1 parent c11c20f commit 862a86e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dali/core/exec/tasking_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST(TaskingTest, IndependentTasksAreParallel) {
auto complete = Task::Create([](){});
for (int i = 0; i < num_threads; i++) {
auto task = Task::Create([&]() {
if (++parallel)
if (++parallel == num_threads)
done = true;
while (!done && std::chrono::high_resolution_clock::now() < timeout) {}
parallel--;
Expand All @@ -58,6 +58,7 @@ TEST(TaskingTest, IndependentTasksAreParallel) {
ex.AddSilentTask(complete);
ex.Wait(complete);
EXPECT_TRUE(done);
EXPECT_EQ(parallel, 0) << "The tasks didn't finish cleanly";
}

TEST(TaskingTest, DependentTasksAreSequential) {
Expand Down Expand Up @@ -87,6 +88,7 @@ TEST(TaskingTest, DependentTasksAreSequential) {
ex.Wait(last_task);
EXPECT_EQ(max_parallel, 1)
<< "The parallelism counter should not exceed 1 for a sequence of dependent tasks.";
EXPECT_EQ(parallel, 0) << "The tasks didn't finish cleanly";
}

TEST(TaskingTest, TaskArgumentValid) {
Expand Down
6 changes: 3 additions & 3 deletions include/dali/core/exec/tasking/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ class Scheduler {
}

private:
/** Checks if the task is ready and moves it from pending_ to ready_ list */
bool DLL_PUBLIC CheckTaskReady(SharedTask &task) noexcept;
/** Acquires all preconditions if they are ready or none if at least one isn't ready */
bool DLL_PUBLIC AcquireAllPreconditions(SharedTask &task) noexcept;

void AddTaskImpl(SharedTask task) {
assert(task->state_ == TaskState::New);
Expand All @@ -257,7 +257,7 @@ class Scheduler {
assert(added);
}
pending_.PushFront(task);
if (CheckTaskReady(task))
if (AcquireAllPreconditions(task))
task_ready_.notify_one();
}
}
Expand Down

0 comments on commit 862a86e

Please sign in to comment.