Sha256: c61d75c00428fee2fe42eaaed52f81d37d2c007555250d67ac43b3f932f480ff

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

# -*- encoding: binary -*-
require 'rainbows/rev/thread'

module Rainbows

  # A combination of the Rev and ThreadSpawn models.  This allows Ruby
  # Thread-based concurrency for application processing.  It DOES NOT
  # expose a streamable "rack.input" for upload processing within the
  # app.  DevFdResponse should be used with this class to proxy
  # asynchronous responses.  All network I/O between the client and
  # server are handled by the main thread and outside of the core
  # application dispatch.
  #
  # Unlike ThreadSpawn, Rev makes this model highly suitable for
  # slow clients and applications with medium-to-slow response times
  # (I/O bound), but less suitable for sleepy applications.
  #
  # Ruby 1.8 users are strongly advised to use Rev >= 0.3.2 to get
  # usable performance.

  module RevThreadSpawn

    class Client < Rainbows::Rev::ThreadClient
      def app_dispatch
        Thread.new(self) { |client| MASTER << [ client, app_response ] }
      end
    end

    include Rainbows::Rev::Core

    def init_worker_process(worker)
      super
      master = Rev::Master.new(Queue.new).attach(::Rev::Loop.default)
      Client.const_set(:MASTER, master)
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rainbows-0.94.0 lib/rainbows/rev_thread_spawn.rb
rainbows-0.93.0 lib/rainbows/rev_thread_spawn.rb
rainbows-0.92.0 lib/rainbows/rev_thread_spawn.rb
rainbows-0.91.1 lib/rainbows/rev_thread_spawn.rb
rainbows-0.91.0 lib/rainbows/rev_thread_spawn.rb
rainbows-0.90.2 lib/rainbows/rev_thread_spawn.rb