Skip to content

Commit

Permalink
reduce scope of task group
Browse files Browse the repository at this point in the history
The code was normally fine, but potentially problematic depending on
thread provider to delete the thread pool prior to waiting for all the
tasks to finish

Signed-off-by: Kimball Thurston <[email protected]>
  • Loading branch information
kdt3rd committed Sep 29, 2024
1 parent b657ecd commit fe8dcbe
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/test/OpenEXRTest/testMultiPartThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,17 +620,19 @@ generateRandomFile (int partCount, const std::string& fn)
//
// Writing tasks.
//
TaskGroup taskGroup;
ThreadPool* threadPool = new ThreadPool (32);
vector<WritingTaskData*> list;
for (int i = 0; i < taskListSize; i++)
{
list.push_back (&taskList[i]);
if (i % 10 == 0 || i == taskListSize - 1)
TaskGroup taskGroup;
vector<WritingTaskData*> list;
for (int i = 0; i < taskListSize; i++)
{
threadPool->addTask (
(new WritingTask (&taskGroup, &file, list, tiledFrameBuffers)));
list.clear ();
list.push_back (&taskList[i]);
if (i % 10 == 0 || i == taskListSize - 1)
{
threadPool->addTask (
(new WritingTask (&taskGroup, &file, list, tiledFrameBuffers)));
list.clear ();
}
}
}

Expand Down

0 comments on commit fe8dcbe

Please sign in to comment.