Skip to content

Commit bcd4c6b

Browse files
leongrossdeadprogram
authored andcommitted
builder: nits
remove unused job state enum, nits/reformatting Signed-off-by: leongross <leon.gross@9elements.com>
1 parent 37460ad commit bcd4c6b

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

builder/jobs.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ import (
1717
// concurrency or performance issues.
1818
const jobRunnerDebug = false
1919

20-
type jobState uint8
21-
22-
const (
23-
jobStateQueued jobState = iota // not yet running
24-
jobStateRunning // running
25-
jobStateFinished // finished running
26-
)
27-
2820
// compileJob is a single compiler job, comparable to a single Makefile target.
2921
// It is used to orchestrate various compiler tasks that can be run in parallel
3022
// but that have dependencies and thus have limitations in how they can be run.
@@ -55,12 +47,11 @@ func dummyCompileJob(result string) *compileJob {
5547
// ordered as such in the job dependencies.
5648
func runJobs(job *compileJob, sema chan struct{}) error {
5749
if sema == nil {
58-
// Have a default, if the semaphore isn't set. This is useful for
59-
// tests.
50+
// Have a default, if the semaphore isn't set. This is useful for tests.
6051
sema = make(chan struct{}, runtime.NumCPU())
6152
}
6253
if cap(sema) == 0 {
63-
return errors.New("cannot 0 jobs at a time")
54+
return errors.New("cannot run 0 jobs at a time")
6455
}
6556

6657
// Create a slice of jobs to run, where all dependencies are run in order.
@@ -81,10 +72,10 @@ func runJobs(job *compileJob, sema chan struct{}) error {
8172

8273
waiting := make(map[*compileJob]map[*compileJob]struct{}, len(jobs))
8374
dependents := make(map[*compileJob][]*compileJob, len(jobs))
84-
jidx := make(map[*compileJob]int)
75+
compileJobs := make(map[*compileJob]int)
8576
var ready intHeap
8677
for i, job := range jobs {
87-
jidx[job] = i
78+
compileJobs[job] = i
8879
if len(job.dependencies) == 0 {
8980
// This job is ready to run.
9081
ready.Push(i)
@@ -105,8 +96,7 @@ func runJobs(job *compileJob, sema chan struct{}) error {
10596
// Create a channel to accept notifications of completion.
10697
doneChan := make(chan *compileJob)
10798

108-
// Send each job in the jobs slice to a worker, taking care of job
109-
// dependencies.
99+
// Send each job in the jobs slice to a worker, taking care of job dependencies.
110100
numRunningJobs := 0
111101
var totalTime time.Duration
112102
start := time.Now()
@@ -156,7 +146,7 @@ func runJobs(job *compileJob, sema chan struct{}) error {
156146
delete(wait, completed)
157147
if len(wait) == 0 {
158148
// This job is now ready to run.
159-
ready.Push(jidx[j])
149+
ready.Push(compileJobs[j])
160150
delete(waiting, j)
161151
}
162152
}

0 commit comments

Comments
 (0)