1 # -*- encoding: binary -*-
3 # used to wrap a BasicSocket to use with +q+ for all writes
4 # this is compatible with IO.select
5 class Rainbows::WriterThreadSpawn::Client < Struct.new(:to_io, :q, :thr)
6 include Rainbows::Response
7 include Rainbows::SocketProxy
8 include Rainbows::WorkerYield
14 CUR.delete_if do |t,q|
17 t.alive? ? t.join(0.01) : true
24 t.alive? ? t.join(0) : true
25 }.size >= MAX and worker_yield
29 self.thr = Thread.new(to_io, q) do |io, q|
30 while response = q.shift
32 arg1, arg2, arg3 = response
34 when :body then write_body(io, arg2, arg3)
36 io.close unless io.closed?
42 Rainbows::Error.write(io, e)
45 CUR.delete(Thread.current)
51 (self.q ||= queue_writer) << buf
54 def queue_body(body, range)
55 (self.q ||= queue_writer) << [ :body, body, range ]