Skip to content

Commit fe8dcbe

Browse files
committed
reduce scope of task group
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]>
1 parent b657ecd commit fe8dcbe

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/test/OpenEXRTest/testMultiPartThreading.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,17 +620,19 @@ generateRandomFile (int partCount, const std::string& fn)
620620
//
621621
// Writing tasks.
622622
//
623-
TaskGroup taskGroup;
624623
ThreadPool* threadPool = new ThreadPool (32);
625-
vector<WritingTaskData*> list;
626-
for (int i = 0; i < taskListSize; i++)
627624
{
628-
list.push_back (&taskList[i]);
629-
if (i % 10 == 0 || i == taskListSize - 1)
625+
TaskGroup taskGroup;
626+
vector<WritingTaskData*> list;
627+
for (int i = 0; i < taskListSize; i++)
630628
{
631-
threadPool->addTask (
632-
(new WritingTask (&taskGroup, &file, list, tiledFrameBuffers)));
633-
list.clear ();
629+
list.push_back (&taskList[i]);
630+
if (i % 10 == 0 || i == taskListSize - 1)
631+
{
632+
threadPool->addTask (
633+
(new WritingTask (&taskGroup, &file, list, tiledFrameBuffers)));
634+
list.clear ();
635+
}
634636
}
635637
}
636638

0 commit comments

Comments
 (0)