You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fiber will yield false because JRuby spawns a new Thread calling Fiber#new. The fiber will yield true on MRI though.
Looking at the logs, the commit introducing this thread creation (i.e. 0a8680cf) is the initial commit of the RubyFiber.java file so we have no information about this.
This has been tested with JRuby 1.7.13 and current master.
I can confirm this still exists on JRuby 1.7.19/9.0.0.0.pre1. It can lead to some fun issues when you try to reuse threads using Thread.current, like statsd-ruby or net-http-persistent and something that uses Fibers like Celluloid/Sidekiq.
This has come up many times, and it's not an easy thing to fix. The main issue is that our Fiber subsystem uses normal Ruby synchronization mechanisms (specifically, Queue) which depends on the Fiber and the Thread it's synchronizing against to have their own notions of current thread.
However, since I wrote this implementation, we have improved our internal logic for synchronizing threads with non-Ruby mechanisms without interfering in Ruby signalling. This can be revisited, but most likely not until 9.2.
On Feb 13, 2018, at 09:25, Charles Oliver Nutter ***@***.***> wrote:
This has come up many times, and it's not an easy thing to fix. The main issue is that our Fiber subsystem uses normal Ruby synchronization mechanisms (specifically, Queue) which depends on the Fiber and the Thread it's synchronizing against to have their own notions of current thread.
However, since I wrote this implementation, we have improved our internal logic for synchronizing threads with non-Ruby mechanisms without interfering in Ruby signalling. This can be revisited, but most likely not until 9.2.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
FWIW there is now a working coroutine implementation for OpenJDK: Project Loom. Given a bit of time (or help from the community) we could ship pre-release support for it in JRuby any day now. Maybe for 9.2.2?
The latest PR has been rebased on current 9.4 but it's too drastic a change to make now right before release. It will fit better with the more extensive changes planned for 9.5 (planned for mid-2023), so I have retargeted it.
It's also worth mentioning that since this PR came out, a number of changes have happened to fibers that makes this change less important, like adding explicitly fiber-local values and other fiber-specific versions of per-thread functions.
Activity
zanker commentedon Feb 12, 2015
I can confirm this still exists on JRuby 1.7.19/9.0.0.0.pre1. It can lead to some fun issues when you try to reuse threads using
Thread.current, like statsd-ruby or net-http-persistent and something that uses Fibers like Celluloid/Sidekiq.chuckremes commentedon Feb 3, 2018
This issue is also still causing headaches. See issue 2 in
ruby-iofor details.headius commentedon Feb 13, 2018
This has come up many times, and it's not an easy thing to fix. The main issue is that our Fiber subsystem uses normal Ruby synchronization mechanisms (specifically, Queue) which depends on the Fiber and the Thread it's synchronizing against to have their own notions of current thread.
However, since I wrote this implementation, we have improved our internal logic for synchronizing threads with non-Ruby mechanisms without interfering in Ruby signalling. This can be revisited, but most likely not until 9.2.
zanker commentedon Feb 13, 2018
headius commentedon Sep 19, 2018
FWIW there is now a working coroutine implementation for OpenJDK: Project Loom. Given a bit of time (or help from the community) we could ship pre-release support for it in JRuby any day now. Maybe for 9.2.2?
24 remaining items
headius commentedon Oct 7, 2021
This didn't make the cut for 9.3, which we wanted to get out the door to work on Ruby 3.0 support in 9.4. Punting to 9.4 to reevaluate.
headius commentedon Nov 16, 2022
The latest PR has been rebased on current 9.4 but it's too drastic a change to make now right before release. It will fit better with the more extensive changes planned for 9.5 (planned for mid-2023), so I have retargeted it.
It's also worth mentioning that since this PR came out, a number of changes have happened to fibers that makes this change less important, like adding explicitly fiber-local values and other fiber-specific versions of per-thread functions.
Return Fiber's parent thread for Thread.current
Return Fiber's parent thread for Thread.current
Return Fiber's parent thread for Thread.current