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

Support passing the result of one task into other tasks #1

Merged
merged 3 commits into from
Sep 3, 2018

Conversation

ztstewart
Copy link
Owner

This PR changes the function signature of the task function to both return an empty interface and accept a new Results type. This type is a simple struct that holds a reference to a sync.Map, letting each task atomically and concurrently write their results and retrieve the results in later tasks.

The idea is that, currently, users of this library have to declare variables global to a function to pass data around. While this has maximum type safety, it is also somewhat cumbersome, and introduces the possible error of forgetting to set a vale.

This PR makes a different trade-off. It argues that strict type safety is slightly overrated in the absence of polymorphic parametricity. Personally I'd rather be able to do NewGraph<ResultTypeHere>(....) a la Java but if Go is Java 1.4 might as well unleash the power of casting before contracts.

@ztstewart ztstewart self-assigned this Sep 3, 2018
@ztstewart ztstewart merged commit c1241ec into master Sep 3, 2018
@ztstewart ztstewart deleted the zts/maps branch September 3, 2018 18:16
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.

1 participant