-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix select with receive? and closed channels #8304
Merged
bcardiff
merged 13 commits into
crystal-lang:master
from
bcardiff:mt/select-closed-channel
Oct 11, 2019
Merged
Fix select with receive? and closed channels #8304
bcardiff
merged 13 commits into
crystal-lang:master
from
bcardiff:mt/select-closed-channel
Oct 11, 2019
Conversation
This file contains 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
firejox
reviewed
Oct 10, 2019
kostya
reviewed
Oct 10, 2019
For c : Channel(T), _, m1 = Channel.non_blocking_select(c.receive_select_action) _, m2 = Channel.select(c.receive_select_action) We will want to m1 : T | NotReady m2 : T So they need to be different methods and not just a change of behavior depending on the argument.
extend self is nice, but the typeof(M) == M:Module when module M; extend self, and it looks weird.
Check none of the channels are initially closed via SelectAction#available?
c1cd9ef
to
afb5357
Compare
squashed fixups and rebased on master after today's review to improve the helper methods. |
waj
approved these changes
Oct 11, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
This PR implements https://gist.github.com/bcardiff/289953a80eb3a0512a2a2f8c8dfeb1db while fixing the behavior of
select
over closed or closing channels.The main guidance where:
Channel#receive
vsChannel#receive?
differs on their behavior for closed channels. Using them directly is always blocking.There was a need to extend the design of
SelectAction
and some overload/exceptions were used used to make typing work.Regarding typing, blocking and non-blocking select have different methods so their typing can differ. Blocking select will never return
NotReady
.Closes #8301
Fixes #8300
Follow up of #8243 (comment)