Skip to content

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

Merged
merged 2 commits into from
Jun 12, 2019
Merged

Implement non-blocking select statements #402

merged 2 commits into from
Jun 12, 2019

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Jun 8, 2019

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.

@deadprogram
Copy link
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.
@aykevl aykevl force-pushed the implement-select branch from deb75b8 to 3501131 Compare June 8, 2019 21:00
@aykevl
Copy link
Member Author

aykevl commented Jun 8, 2019

Rebased.

// 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
Copy link
Member

Choose a reason for hiding this comment

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

fashion

// A receive operation.
switch state.ch.state {
case chanStateSend:
println(" state send")
Copy link
Member

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...

}
return uintptr(i), true // commaOk = true
case chanStateClosed:
println(" state closed")
Copy link
Member

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
Copy link
Member

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.
@aykevl aykevl force-pushed the implement-select branch from 3501131 to 81826a2 Compare June 12, 2019 11:33
@aykevl
Copy link
Member Author

aykevl commented Jun 12, 2019

Oh that was really sloppy of me, thanks for checking. Fixed now.

@aykevl
Copy link
Member Author

aykevl commented Jun 12, 2019

The test is flaky, re-running now.

@deadprogram
Copy link
Member

IMO this is a very big leap forward in one of the few missing language features. Great work!

@deadprogram deadprogram merged commit b7197bc into dev Jun 12, 2019
@deadprogram deadprogram deleted the implement-select branch June 12, 2019 16:26
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.

2 participants