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

runtime.Gosched usage is likely to lead readers astray #21

Open
raggi opened this issue Aug 8, 2016 · 4 comments
Open

runtime.Gosched usage is likely to lead readers astray #21

raggi opened this issue Aug 8, 2016 · 4 comments

Comments

@raggi
Copy link

raggi commented Aug 8, 2016

While this might well be the shortest way you found to demonstrate the output you wanted, training users toward this function stands a good chance of them trying to use it to solve early problems it is not suitable for.

@thewhitetulip
Copy link
Owner

thewhitetulip commented Aug 8, 2016

this one right?

func say(s string) {
    for i := 0; i < 5; i++ {
        runtime.Gosched()
        fmt.Println(s)
    }
}

The thing is, this chapter is adapted from the book by @astaxie.

I will make some modifications to the description.

@thewhitetulip
Copy link
Owner

@raggi I now have time for looking into this, do you suggest any alternate mechanism that is simpler for new comers to understand?

@raggi
Copy link
Author

raggi commented Aug 28, 2016

It's a fair question. The thing is that since GOMAXPROCS is now defaulted to a higher value and most users will not be on single core systems, I'm not sure you'll need this in order to demonstrate parallelism, it just won't be even. In future versions of Go, this may not be even anyway.

Maybe you'll want to set GOMAXPROCS to 4 just to be certain, but that's also mostly unnecessary.

@thewhitetulip
Copy link
Owner

Okay, so shall I remove this example and put in a basic one if it isn't present

func main(){
    go say()
}

And remove the example you are talking about?

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

No branches or pull requests

2 participants