Merge pull request #30 from mlemanczyk/codex/fix-exception-in-resultsparser
Fix worker index capture causing split results failure
This commit is contained in:
1 file changed
+25
-24
@@ -625,11 +625,11 @@ internal static class Program
|
|||||||
int start = 0;
|
int start = 0;
|
||||||
int baseChunk = count / workerCount;
|
int baseChunk = count / workerCount;
|
||||||
int remainder = count % workerCount;
|
int remainder = count % workerCount;
|
||||||
for (int worker = 0; worker < workerCount; worker++)
|
for (int worker = 0; worker < workerCount; worker++)
|
||||||
{
|
{
|
||||||
int length = baseChunk + (worker < remainder ? 1 : 0);
|
int length = baseChunk + (worker < remainder ? 1 : 0);
|
||||||
int chunkStart = start;
|
int chunkStart = start;
|
||||||
start += length;
|
start += length;
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
@@ -639,27 +639,28 @@ internal static class Program
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks[worker] = Task.Run(() =>
|
int workerIndex = worker;
|
||||||
{
|
tasks[workerIndex] = Task.Run(() =>
|
||||||
List<CandidateResult> localPassed = new(length);
|
{
|
||||||
List<CandidateResult> localRejected = new(length);
|
List<CandidateResult> localPassed = new(length);
|
||||||
int end = chunkStart + length;
|
List<CandidateResult> localRejected = new(length);
|
||||||
for (int i = chunkStart; i < end; i++)
|
int end = chunkStart + length;
|
||||||
{
|
for (int i = chunkStart; i < end; i++)
|
||||||
CandidateResult candidate = sortedResults[i];
|
{
|
||||||
if (candidate.PassedAllTests)
|
CandidateResult candidate = sortedResults[i];
|
||||||
{
|
if (candidate.PassedAllTests)
|
||||||
localPassed.Add(candidate);
|
{
|
||||||
continue;
|
localPassed.Add(candidate);
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
localRejected.Add(candidate);
|
localRejected.Add(candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
passedSegments[worker] = localPassed;
|
passedSegments[workerIndex] = localPassed;
|
||||||
rejectedSegments[worker] = localRejected;
|
rejectedSegments[workerIndex] = localRejected;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.WaitAll(tasks);
|
Task.WaitAll(tasks);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user