diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-08-24 23:03:17 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-08-27 20:07:04 +0000 |
commit | e794a40049959a23ba311c572e518bb7c2861812 (patch) | |
tree | b97f197cc66f51a7844edb0ca3bff84e65abafde | |
parent | 12281e4cee86496588814cd1851e8764caea024c (diff) | |
download | rainbows-e794a40049959a23ba311c572e518bb7c2861812.tar.gz |
Also clarify the code while we're at it. Thanks to Lin Jen-Shin for pointing this out. ref: http://mid.gmane.org/CAA2_N1unOXb7Z4Jr8oKoSLu266O9Ko4o=oWzAcMA1w3=9X74KA@mail.gmail.com
-rw-r--r-- | lib/rainbows/fiber/base.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/rainbows/fiber/base.rb b/lib/rainbows/fiber/base.rb index 00af214..e8f5b16 100644 --- a/lib/rainbows/fiber/base.rb +++ b/lib/rainbows/fiber/base.rb @@ -51,8 +51,16 @@ module Rainbows::Fiber::Base end } fibs.each { |fib| fib.resume } - now = Time.now - max.nil? || max > (now + 1) ? 1 : max - now + + max_sleep = 1.0 # wake up semi-frequently to prevent SIGKILL from master + if max + max -= Time.now + return 0 if max < 0.0 + return max_sleep if max > max_sleep + max + else + max_sleep + end end def process(client) |