Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to use goroutines for mulitple async depedency resolution #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hemc4
Copy link

@hemc4 hemc4 commented Mar 20, 2017

#3

@coveralls
Copy link

coveralls commented Mar 20, 2017

Coverage Status

Coverage decreased (-5.7%) to 84.343% when pulling 39ee389 on hemc4:master into f23af3e on KyleBanks:master.

}

// parse constructs a depth.Tree from command-line arguments.
func parse(args []string) *depth.Tree {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@KyleBanks KyleBanks mentioned this pull request Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants