Merge pull request #9575 from Icinga/WorkQueue-ParallelFor

WorkQueue#ParallelFor(): allocate lambda once per thread, not once per item
This commit is contained in:
Alexander Aleksandrovič Klimov 2024-02-14 12:59:50 +01:00 committed by GitHub
commit 1a8ce5a90e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -89,10 +89,13 @@ public:
count++; count++;
EnqueueUnlocked(lock, [&items, func, offset, count, this]() { EnqueueUnlocked(lock, [&items, func, offset, count, this]() {
for (SizeType j = offset; j < offset + count; j++) { SizeType j;
RunTaskFunction([&func, &items, j]() { TaskFunction f = [&func, &items, &j]() {
func(items[j]); func(items[j]);
}); };
for (j = offset; j < offset + count; j++) {
RunTaskFunction(f);
} }
}); });