-
Notifications
You must be signed in to change notification settings - Fork 5
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
Thread#join sometimes doesn't wake up when thread terminates #4
Comments
Does this patch look like a reasonable fix? It fixes this particular case, at least. diff --git a/lib/fiber_scheduler/selector.rb b/lib/fiber_scheduler/selector.rb
index 068b390..172f18c 100644
--- a/lib/fiber_scheduler/selector.rb
+++ b/lib/fiber_scheduler/selector.rb
@@ -206,7 +206,7 @@ class FiberScheduler
end
end
- duration = 0 if @ready.any?
+ duration = 0 if @ready.any? or (readable.empty? and writable.empty?)
readable, writable, _ = IO.select(readable, writable, nil, duration)
ready = Hash.new(0)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using fiber_scheduler 0.13.0. Here's my code:
Sometimes
t.join 3
returns quickly, which is what I want to happen since threadt
almost immediately terminates. However, usuallyt.join 3
takes 3 seconds to return, which means something (the fiber scheduler, I think) preventedt.join
from waking up early.By adding debug logging to fiber_scheduler, I've figured out two things:
t.join 3
returns quickly, it's becauseFiberScheduler::Selector#select
calledIO.select([], [], nil, 0)
t.join 3
returns after 3 seconds, it's becauseFiberScheduler::Selector#select
calledIO.select([], [], nil, 3)
This feels like a bug in fiber_scheduler. Am I right?
(If it matters, I'm using Linux on x86_64, and I installed fiber_scheduler through Bundler.)
The text was updated successfully, but these errors were encountered: