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

Select in some cases hangs forever #3862

Closed
kostya opened this issue Jan 8, 2017 · 0 comments
Closed

Select in some cases hangs forever #3862

kostya opened this issue Jan 8, 2017 · 0 comments
Labels
community:in-progress kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:concurrency

Comments

@kostya
Copy link
Contributor

kostya commented Jan 8, 2017

this works as expected:

ch1 = Channel(Int32).new
ch2 = Channel(Bool).new

spawn do
  select
  when val = ch1.receive
    p val
    exit
  when ch2.receive
    p :not_happen
  end
end

spawn do
  select
  when ch1.send(1)
    p :sended
  when ch2.receive
    p :not_happen
  end
end

sleep

output 1 and exit.

but if i change order of receive and send, it hangs forever, but expected to work.

ch1 = Channel(Int32).new
ch2 = Channel(Bool).new

spawn do
  select
  when ch1.send(1)
    p :sended
  when ch2.receive
    p :not_happen
  end
end

spawn do
  select
  when val = ch1.receive
    p val
    exit
  when ch2.receive
    p :not_happen
  end
end

sleep
@spalladino spalladino changed the title select in some cases hangs forever Select in some cases hangs forever Jan 9, 2017
@spalladino spalladino added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:concurrency labels Jan 9, 2017
firejox added a commit to firejox/crystal that referenced this issue Jan 22, 2017
- Fixes crystal-lang#3900 crystal-lang#3862
- Fully thread safe except coroutine switch
firejox added a commit to firejox/crystal that referenced this issue Jan 26, 2017
- Fixes crystal-lang#3900 crystal-lang#3862
- Fully thread safe except coroutine switch
firejox added a commit to firejox/crystal that referenced this issue Jan 26, 2017
- Fixes crystal-lang#3900 crystal-lang#3862
- Fully thread safe except coroutine switch
firejox added a commit to firejox/crystal that referenced this issue Jan 26, 2017
- Fixes crystal-lang#3900 crystal-lang#3862
- Fully thread safe except coroutine switch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community:in-progress kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:concurrency
Projects
None yet
Development

No branches or pull requests

2 participants