Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce6c187

Browse files
committed
Defaults to runtime.NumCPU() if specified jobs number is 0
1 parent0785c72 commitce6c187

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

‎commands/compile/compile.go‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"fmt"
2424
"io"
2525
"path/filepath"
26-
"runtime"
2726
"sort"
2827
"strings"
2928

@@ -116,11 +115,7 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W
116115

117116
builderCtx.CoreBuildCachePath=paths.TempDir().Join("arduino-core-cache")
118117

119-
jobs:=runtime.NumCPU()
120-
ifreq.GetJobs()>0 {
121-
jobs=int(req.GetJobs())
122-
}
123-
builderCtx.Jobs=jobs
118+
builderCtx.Jobs=int(req.GetJobs())
124119

125120
builderCtx.USBVidPid=req.GetVidPid()
126121
builderCtx.WarningsLevel=req.GetWarnings()

‎legacy/builder/builder_utils/utils.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"os"
3434
"os/exec"
3535
"path/filepath"
36+
"runtime"
3637
"strconv"
3738
"strings"
3839
"sync"
@@ -192,7 +193,11 @@ func compileFilesWithRecipe(ctx *types.Context, sourcePath *paths.Path, sources
192193

193194
// Spawn jobs runners
194195
varwg sync.WaitGroup
195-
fori:=0;i<ctx.Jobs;i++ {
196+
jobs:=ctx.Jobs
197+
ifjobs==0 {
198+
jobs=runtime.NumCPU()
199+
}
200+
fori:=0;i<jobs;i++ {
196201
wg.Add(1)
197202
gofunc() {
198203
forsource:=rangequeue {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp