-
Notifications
You must be signed in to change notification settings - Fork 952
Implement non-blocking select statements #402
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
Conversation
Ready for conflict resolution, please. |
This may have a small effect on code size sometimes, but will simplify the implementation of the select statement.
Rebased. |
src/runtime/chan.go
Outdated
// perhaps the most complicated statement in the Go spec. It returns the | ||
// selected index and the 'comma-ok' value. | ||
// | ||
// TODO: do this in a round-robin fashin (as specified in the Go spec) instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fashion
src/runtime/chan.go
Outdated
// A receive operation. | ||
switch state.ch.state { | ||
case chanStateSend: | ||
println(" state send") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably did not mean to leave this here...
src/runtime/chan.go
Outdated
} | ||
return uintptr(i), true // commaOk = true | ||
case chanStateClosed: | ||
println(" state closed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
const ( | ||
chanStateEmpty = iota | ||
chanStateEmpty chanState = iota |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Blocking selects are much more complicated, so let's do non-blocking ones first.
Oh that was really sloppy of me, thanks for checking. Fixed now. |
The test is flaky, re-running now. |
IMO this is a very big leap forward in one of the few missing language features. Great work! |
Non-blocking selects are much easier to implement, so let's do that first. It should get a bit more code to compile as well (but not necessarily to run well). It depends on #401 because there would be merge conflicts otherwise.
And yes, this is also part of #285 because the time package contains a select that used to be not compiled but will be with that refactor.