diff options
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 |