Updated to use goroutines for mulitple async depedency resolution#7
Updated to use goroutines for mulitple async depedency resolution#7hemc4 wants to merge 1 commit intoKyleBanks:masterfrom hemc4:master
Conversation
| } | ||
|
|
||
| // parse constructs a depth.Tree from command-line arguments. | ||
| func parse(args []string) *depth.Tree { |
There was a problem hiding this comment.
Now that you're using the WaitGroup and not channels I think you can keep the parse method + test
| continue | ||
| } | ||
| wg.Add(1) | ||
| go handlePkg(&wg, t, pkg, outputJSON) |
There was a problem hiding this comment.
I'm not sure reusing the same Tree concurrently is going to be safe, because resolving modified properties on the tree itself. If you put the parse method back, you could call parse within this for-loop to get a fresh tree for each package
| if outputJSON { | ||
| writePkgJSON(os.Stdout, *t.Root) | ||
| } else { | ||
| writePkg(os.Stdout, *t.Root, 0, false) |
There was a problem hiding this comment.
One last concern is printing, since this is going to happen concurrently the output may not always be cleanly separated by package, if that make sense. For example you may get halfway through printing PackageA's tree when PackageB starts printing
There was a problem hiding this comment.
Actually, I was using channels for solving this problem, where we send the tree struct with config and return the final filled tree to channel and then print it. In this approach problem was the pkg.go returns from multiple places, the channel needs to set for every return case to avoid a leak.
#3