We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b6079a3 + f383714 commit 8ff933bCopy full SHA for 8ff933b
sort/sort.go
@@ -25,7 +25,13 @@ func MultithreadedSortComparators(comparators Comparators) Comparators {
25
copy(toBeSorted, comparators)
26
27
var wg sync.WaitGroup
28
- chunks := chunk(toBeSorted, int64(runtime.NumCPU()))
+
29
+ numCPU := int64(runtime.NumCPU())
30
+ if numCPU%2 == 1 { // single core machine
31
+ numCPU++
32
+ }
33
34
+ chunks := chunk(toBeSorted, numCPU)
35
wg.Add(len(chunks))
36
for i := 0; i < len(chunks); i++ {
37
go func(i int) {
0 commit comments