mirror of https://github.com/Icinga/icinga2.git
Merge pull request #9575 from Icinga/WorkQueue-ParallelFor
WorkQueue#ParallelFor(): allocate lambda once per thread, not once per item
This commit is contained in:
commit
1a8ce5a90e
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue