WorkQueue#ParallelFor(): allocate lambda once per thread, not once per item

This commit is contained in:
Alexander A. Klimov 2022-11-09 12:18:21 +01:00
parent f59f361f09
commit ba62c665aa

View File

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