about summary refs log tree commit homepage
path: root/lib/rainbows/writer_thread_pool/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/writer_thread_pool/client.rb')
-rw-r--r--lib/rainbows/writer_thread_pool/client.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/rainbows/writer_thread_pool/client.rb b/lib/rainbows/writer_thread_pool/client.rb
new file mode 100644
index 0000000..5889e84
--- /dev/null
+++ b/lib/rainbows/writer_thread_pool/client.rb
@@ -0,0 +1,19 @@
+# -*- encoding: binary -*-
+#
+# used to wrap a BasicSocket to use with +q+ for all writes
+# this is compatible with IO.select
+class Rainbows::WriterThreadPool::Client < Struct.new(:to_io, :q) # :nodoc:
+  include Rainbows::SocketProxy
+
+  def write(buf)
+    q << [ to_io, buf ]
+  end
+
+  def close
+    q << [ to_io, :close ]
+  end
+
+  def closed?
+    false
+  end
+end