Implement non-blocking select statements#402
Merged
deadprogram merged 2 commits intodevfrom Jun 12, 2019
Merged
Conversation
Member
|
Ready for conflict resolution, please. |
This may have a small effect on code size sometimes, but will simplify the implementation of the select statement.
Member
Author
|
Rebased. |
deadprogram
reviewed
Jun 12, 2019
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 |
deadprogram
reviewed
Jun 12, 2019
src/runtime/chan.go
Outdated
| // A receive operation. | ||
| switch state.ch.state { | ||
| case chanStateSend: | ||
| println(" state send") |
Member
There was a problem hiding this comment.
You probably did not mean to leave this here...
deadprogram
reviewed
Jun 12, 2019
src/runtime/chan.go
Outdated
| } | ||
| return uintptr(i), true // commaOk = true | ||
| case chanStateClosed: | ||
| println(" state closed") |
deadprogram
reviewed
Jun 12, 2019
|
|
||
| const ( | ||
| chanStateEmpty = iota | ||
| chanStateEmpty chanState = iota |
Blocking selects are much more complicated, so let's do non-blocking ones first.
Member
Author
|
Oh that was really sloppy of me, thanks for checking. Fixed now. |
Member
Author
|
The test is flaky, re-running now. |
Member
|
IMO this is a very big leap forward in one of the few missing language features. Great work! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.