message: Fixed synchronization bug in Common_ThreadPool.Priorities
diff: @@ -293,16 +293,23 @@ TEST(Common_ThreadPool, Priorities)
  {
  constexpr Uint32 NumThreads = 1;
  constexpr Uint32 NumTasks = 8;
  + constexpr Uint32 RepeatCount = 10;
  + for (Uint32 k = 0; k < RepeatCount; ++k)
  + {
  auto pThreadPool = CreateThreadPool(ThreadPoolCreateInfo{NumThreads});
  ASSERT_NE(pThreadPool, nullptr);
  ThreadingTools::Signal Signal;
  + RefCntAutoPtr<WaitTask> pWaitTask;
  {
  - auto Task = MakeNewRCObj<WaitTask>()(Signal, NumThreads);
  - pThreadPool->EnqueueTask(Task);
  + pWaitTask = MakeNewRCObj<WaitTask>()(Signal, NumThreads);
  + pThreadPool->EnqueueTask(pWaitTask);
  }
  + // Wait until the task is running to make sure that higher-priority tasks don't start first
  + pWaitTask->WaitUntilRunning();
  +
  std::vector<int> CompletionOrder;
  CompletionOrder.reserve(NumTasks);
  std::array<RefCntAutoPtr<IAsyncTask>, NumTasks> Tasks;
  @@ -330,6 +337,7 @@ TEST(Common_ThreadPool, Priorities)
  // The tasks can't start since the thread is waiting for the signal
  EXPECT_GE(pThreadPool->GetQueueSize(), Tasks.size());
  + EXPECT_FALSE(pWaitTask->IsFinished());
  Signal.Trigger(true, 1);
  @@ -338,7 +346,8 @@ TEST(Common_ThreadPool, Priorities)
  const std::vector<int> ExpectedOrder = {7, 4, 5, 1, 0, 2, 3, 6};
  ASSERT_EQ(ExpectedOrder.size(), CompletionOrder.size());
  for (size_t i = 0; i < ExpectedOrder.size(); ++i)
  - EXPECT_EQ(ExpectedOrder[i], CompletionOrder[i]) << "i=" << i;
  + EXPECT_EQ(ExpectedOrder[i], CompletionOrder[i]) << "i=" << i << " (N=" << k << ")";
  + }
  }
  } // namespace
  