about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-20 03:41:48 +0000
committerEric Wong <normalperson@yhbt.net>2010-12-20 03:42:55 +0000
commit886e0a006d9e8e9c586beae28ed4dc5097064e90 (patch)
tree6aa8c96e039e27c6b41a5ed1cd685b8252448723
parent7e2bb251228a30c0d4e66029b20bbbf85bc99a09 (diff)
downloadrainbows-886e0a006d9e8e9c586beae28ed4dc5097064e90.tar.gz
Because of the lack of GVL-releasing syscalls in this branch
of the thread loop, we need Thread.pass to ensure other threads
get scheduled appropriately under 1.9.  This is likely a threading
bug in 1.9 that warrants further investigation when we're in a
better mood.
-rw-r--r--lib/rainbows/thread_timeout.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rainbows/thread_timeout.rb b/lib/rainbows/thread_timeout.rb
index f34c0d4..b9f6025 100644
--- a/lib/rainbows/thread_timeout.rb
+++ b/lib/rainbows/thread_timeout.rb
@@ -73,7 +73,13 @@ class Rainbows::ThreadTimeout
       begin
         if next_wake = @lock.synchronize { @active.values }.min
           next_wake -= Time.now
-          sleep(next_wake) if next_wake > 0
+
+          # because of the lack of GVL-releasing syscalls in this branch
+          # of the thread loop, we need Thread.pass to ensure other threads
+          # get scheduled appropriately under 1.9.  This is likely a threading
+          # bug in 1.9 that warrants further investigation when we're in a
+          # better mood.
+          next_wake > 0 ? sleep(next_wake) : Thread.pass
         else
           sleep(@timeout)
         end