diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-27 02:36:58 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-27 02:36:58 +0000 |
commit | a310302708faa19042282e94525544cfbb23eba5 (patch) | |
tree | 3a37f24e0097dc7cb276c3ee3b7ff26239c67ccb /lib/rainbows/writer_thread_spawn/client.rb | |
parent | 6ae020c9ac483d822902b5d33f038f79b44d3a50 (diff) | |
download | rainbows-a310302708faa19042282e94525544cfbb23eba5.tar.gz |
Self-documenting code is easier to follow
Diffstat (limited to 'lib/rainbows/writer_thread_spawn/client.rb')
-rw-r--r-- | lib/rainbows/writer_thread_spawn/client.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/rainbows/writer_thread_spawn/client.rb b/lib/rainbows/writer_thread_spawn/client.rb index 4341b9a..f9c373e 100644 --- a/lib/rainbows/writer_thread_spawn/client.rb +++ b/lib/rainbows/writer_thread_spawn/client.rb @@ -7,6 +7,15 @@ class Rainbows::WriterThreadSpawn::Client < Struct.new(:to_io, :q, :thr) CUR = {} # :nodoc: + def self.quit + g = Rainbows::G + CUR.delete_if do |t,q| + q << nil + g.tick + t.alive? ? t.join(0.01) : true + end until CUR.empty? + end + def queue_writer # not using Thread.pass here because that spins the CPU during # I/O wait and will eat cycles from other worker processes. |