diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-12-01 23:39:32 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-12-02 00:23:02 -0800 |
commit | 154e7af0225a0375274991ee7bd1fc8ad22c1c37 (patch) | |
tree | 2274e7beaa114f88126573830d0bccf7df4c3904 /lib/rainbows/rev/master.rb | |
parent | c50b69ddf0f1305bb39ed812d084f59db6dd9897 (diff) | |
download | rainbows-154e7af0225a0375274991ee7bd1fc8ad22c1c37.tar.gz |
This should be like RevThreadSpawn except with more predictable performance (but higher memory usage under low load).
Diffstat (limited to 'lib/rainbows/rev/master.rb')
-rw-r--r-- | lib/rainbows/rev/master.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/rainbows/rev/master.rb b/lib/rainbows/rev/master.rb new file mode 100644 index 0000000..5c112c6 --- /dev/null +++ b/lib/rainbows/rev/master.rb @@ -0,0 +1,29 @@ +# -*- encoding: binary -*- +require 'rainbows/rev' + +RUBY_VERSION =~ %r{\A1\.8} && ::Rev::VERSION < "0.3.2" and + warn "Rainbows::RevThreadSpawn + Rev (< 0.3.2)" \ + " does not work well under Ruby 1.8" + +module Rainbows + + module Rev + class Master < ::Rev::AsyncWatcher + + def initialize(queue) + super() + @queue = queue + end + + def <<(output) + @queue << output + signal + end + + def on_signal + client, response = @queue.pop + client.response_write(response) + end + end + end +end |