about summary refs log tree commit homepage
path: root/lib/rainbows/writer_thread_spawn/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/writer_thread_spawn/client.rb')
-rw-r--r--lib/rainbows/writer_thread_spawn/client.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/rainbows/writer_thread_spawn/client.rb b/lib/rainbows/writer_thread_spawn/client.rb
index f9c373e..ed60f42 100644
--- a/lib/rainbows/writer_thread_spawn/client.rb
+++ b/lib/rainbows/writer_thread_spawn/client.rb
@@ -4,6 +4,7 @@
 class Rainbows::WriterThreadSpawn::Client < Struct.new(:to_io, :q, :thr)
   include Rainbows::Response
   include Rainbows::SocketProxy
+  include Rainbows::WorkerYield
 
   CUR = {} # :nodoc:
 
@@ -17,12 +18,10 @@ class Rainbows::WriterThreadSpawn::Client < Struct.new(:to_io, :q, :thr)
   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.
     until CUR.size < MAX
       CUR.delete_if { |t,_|
         t.alive? ? t.join(0) : true
-      }.size >= MAX and sleep(0.01)
+      }.size >= MAX and worker_yield
     end
 
     q = Queue.new