Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(304)

Side by Side Diff: src/cmd/go/build.go

Issue 5504080: code review 5504080: cmd/go: two testing fixes (Closed)
Patch Set: diff -r 7287f60ba4e4 https://go.googlecode.com/hg/ Created 13 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/cmd/go/pkg.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "container/heap" 9 "container/heap"
10 "errors" 10 "errors"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // Have to use something other than .a for the suffix. 329 // Have to use something other than .a for the suffix.
330 // It is easier on Windows if we use .exe, so use .exe e verywhere. 330 // It is easier on Windows if we use .exe, so use .exe e verywhere.
331 // (This is the name of a temporary file.) 331 // (This is the name of a temporary file.)
332 a.target = a.objdir + "a.out" + b.exe 332 a.target = a.objdir + "a.out" + b.exe
333 } 333 }
334 } 334 }
335 335
336 return a 336 return a
337 } 337 }
338 338
339 // actionList returns the list of actions in the dag rooted at root
340 // as visited in a depth-first post-order traversal.
341 func actionList(root *action) []*action {
342 seen := map[*action]bool{}
343 all := []*action{}
344 var walk func(*action)
345 walk = func(a *action) {
346 if seen[a] {
347 return
348 }
349 seen[a] = true
350 for _, a1 := range a.deps {
351 walk(a1)
352 }
353 all = append(all, a)
354 }
355 walk(root)
356 return all
357 }
358
339 // do runs the action graph rooted at root. 359 // do runs the action graph rooted at root.
340 func (b *builder) do(root *action) { 360 func (b *builder) do(root *action) {
341 // Build list of all actions, assigning depth-first post-order priority. 361 // Build list of all actions, assigning depth-first post-order priority.
342 // The original implementation here was a true queue 362 // The original implementation here was a true queue
343 // (using a channel) but it had the effect of getting 363 // (using a channel) but it had the effect of getting
344 // distracted by low-level leaf actions to the detriment 364 // distracted by low-level leaf actions to the detriment
345 // of completing higher-level actions. The order of 365 // of completing higher-level actions. The order of
346 // work does not matter much to overall execution time, 366 // work does not matter much to overall execution time,
347 // but when running "go test std" it is nice to see each test 367 // but when running "go test std" it is nice to see each test
348 // results as soon as possible. The priorities assigned 368 // results as soon as possible. The priorities assigned
349 // ensure that, all else being equal, the execution prefers 369 // ensure that, all else being equal, the execution prefers
350 // to do what it would have done first in a simple depth-first 370 // to do what it would have done first in a simple depth-first
351 // dependency order traversal. 371 // dependency order traversal.
352 » all := map[*action]bool{} 372 » all := actionList(root)
353 » priority := 0 373 » for i, a := range all {
354 » var walk func(*action) 374 » » a.priority = i
355 » walk = func(a *action) {
356 » » if all[a] {
357 » » » return
358 » » }
359 » » all[a] = true
360 » » priority++
361 » » for _, a1 := range a.deps {
362 » » » walk(a1)
363 » » }
364 » » a.priority = priority
365 } 375 }
366 walk(root)
367 376
368 b.readySema = make(chan bool, len(all)) 377 b.readySema = make(chan bool, len(all))
369 done := make(chan bool) 378 done := make(chan bool)
370 379
371 // Initialize per-action execution state. 380 // Initialize per-action execution state.
372 » for a := range all { 381 » for _, a := range all {
373 for _, a1 := range a.deps { 382 for _, a1 := range a.deps {
374 a1.triggers = append(a1.triggers, a) 383 a1.triggers = append(a1.triggers, a)
375 } 384 }
376 a.pending = len(a.deps) 385 a.pending = len(a.deps)
377 if a.pending == 0 { 386 if a.pending == 0 {
378 b.ready.push(a) 387 b.ready.push(a)
379 b.readySema <- true 388 b.readySema <- true
380 } 389 }
381 } 390 }
382 391
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 return x 1034 return x
1026 } 1035 }
1027 1036
1028 func (q *actionQueue) push(a *action) { 1037 func (q *actionQueue) push(a *action) {
1029 heap.Push(q, a) 1038 heap.Push(q, a)
1030 } 1039 }
1031 1040
1032 func (q *actionQueue) pop() *action { 1041 func (q *actionQueue) pop() *action {
1033 return heap.Pop(q).(*action) 1042 return heap.Pop(q).(*action)
1034 } 1043 }
OLDNEW
« no previous file with comments | « no previous file | src/cmd/go/pkg.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b