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

Fix select with receive? and closed channels #8304

Merged
merged 13 commits into from
Oct 11, 2019

Conversation

bcardiff
Copy link
Member

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 vs Channel#receive? differs on their behavior for closed channels. Using them directly is always blocking.
  • Performing an operation over a closed and closing the channel during the operation must behave in the same way.

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)

@bcardiff bcardiff requested a review from waj October 10, 2019 17:29
@bcardiff bcardiff added topic:stdlib:concurrency kind:bug A bug in the code. Does not apply to documentation, specs, etc. labels Oct 10, 2019
@bcardiff bcardiff added this to the 0.32.0 milestone Oct 10, 2019
@bcardiff bcardiff force-pushed the mt/select-closed-channel branch from c1cd9ef to afb5357 Compare October 11, 2019 20:00
@bcardiff
Copy link
Member Author

squashed fixups and rebased on master after today's review to improve the helper methods.

@bcardiff bcardiff merged commit 8463046 into crystal-lang:master Oct 11, 2019
@bcardiff bcardiff deleted the mt/select-closed-channel branch December 17, 2019 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:concurrency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Channel#close could renqueue select fiber
4 participants