diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-17 22:42:55 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-17 22:42:55 -0700 |
commit | d838e5ef01471eb12aec42639246946f7b3da4a5 (patch) | |
tree | 6c756529fc1229d30cc8b3d3696f588ca870978d /lib/rainbows/base.rb | |
parent | 394e1aa79d16ed9405e35e3cd3749a7e8c51522a (diff) | |
download | rainbows-d838e5ef01471eb12aec42639246946f7b3da4a5.tar.gz |
Subtraction is a difficult concept for some folks (like myself) to grasp and implement.
Diffstat (limited to 'lib/rainbows/base.rb')
-rw-r--r-- | lib/rainbows/base.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index 3f9db96..a78262e 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -85,14 +85,13 @@ module Rainbows def join_threads(threads, worker) logger.info "Joining threads..." threads.each { |thr| thr[:quit] = true } - t0 = Time.now - timeleft = timeout * 2.0 + expire = Time.now + (timeout * 2.0) m = 0 - while (nr = threads.count { |thr| thr.alive? }) > 0 && timeleft > 0 + while (nr = threads.count { |thr| thr.alive? }) > 0 threads.each { |thr| worker.tmp.chmod(m = 0 == m ? 1 : 0) thr.join(1) - break if (timeleft -= (Time.now - t0)) < 0 + break if Time.now >= expire } end logger.info "Done joining threads. #{nr} left running" |