aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder/jobs.go
diff options
context:
space:
mode:
authorleongross <[email protected]>2024-09-12 14:50:42 +0200
committerRon Evans <[email protected]>2024-09-24 17:42:30 +0100
commitbcd4c6b65872333c9a3582d3db73121c074cb381 (patch)
tree9d47e5532e0afdf8f2c503b38eaa0229fd87874d /builder/jobs.go
parent37460ad60af2601a0412426c229663443c8d8eaa (diff)
downloadtinygo-bcd4c6b65872333c9a3582d3db73121c074cb381.tar.gz
tinygo-bcd4c6b65872333c9a3582d3db73121c074cb381.zip
builder: nits
remove unused job state enum, nits/reformatting Signed-off-by: leongross <[email protected]>
Diffstat (limited to 'builder/jobs.go')
-rw-r--r--builder/jobs.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/builder/jobs.go b/builder/jobs.go
index a23d07534..116887461 100644
--- a/builder/jobs.go
+++ b/builder/jobs.go
@@ -17,14 +17,6 @@ import (
// concurrency or performance issues.
const jobRunnerDebug = false
-type jobState uint8
-
-const (
- jobStateQueued jobState = iota // not yet running
- jobStateRunning // running
- jobStateFinished // finished running
-)
-
// compileJob is a single compiler job, comparable to a single Makefile target.
// It is used to orchestrate various compiler tasks that can be run in parallel
// but that have dependencies and thus have limitations in how they can be run.
@@ -55,12 +47,11 @@ func dummyCompileJob(result string) *compileJob {
// ordered as such in the job dependencies.
func runJobs(job *compileJob, sema chan struct{}) error {
if sema == nil {
- // Have a default, if the semaphore isn't set. This is useful for
- // tests.
+ // Have a default, if the semaphore isn't set. This is useful for tests.
sema = make(chan struct{}, runtime.NumCPU())
}
if cap(sema) == 0 {
- return errors.New("cannot 0 jobs at a time")
+ return errors.New("cannot run 0 jobs at a time")
}
// 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 {
waiting := make(map[*compileJob]map[*compileJob]struct{}, len(jobs))
dependents := make(map[*compileJob][]*compileJob, len(jobs))
- jidx := make(map[*compileJob]int)
+ compileJobs := make(map[*compileJob]int)
var ready intHeap
for i, job := range jobs {
- jidx[job] = i
+ compileJobs[job] = i
if len(job.dependencies) == 0 {
// This job is ready to run.
ready.Push(i)
@@ -105,8 +96,7 @@ func runJobs(job *compileJob, sema chan struct{}) error {
// Create a channel to accept notifications of completion.
doneChan := make(chan *compileJob)
- // Send each job in the jobs slice to a worker, taking care of job
- // dependencies.
+ // Send each job in the jobs slice to a worker, taking care of job dependencies.
numRunningJobs := 0
var totalTime time.Duration
start := time.Now()
@@ -156,7 +146,7 @@ func runJobs(job *compileJob, sema chan struct{}) error {
delete(wait, completed)
if len(wait) == 0 {
// This job is now ready to run.
- ready.Push(jidx[j])
+ ready.Push(compileJobs[j])
delete(waiting, j)
}
}