class CrapServer::ThreadPool

Public Class Methods

new(sockets) click to toggle source
# File lib/crap_server/thread_pool.rb, line 3
def initialize(sockets)
  @sockets = sockets
end

Public Instance Methods

run(&block) click to toggle source
# File lib/crap_server/thread_pool.rb, line 7
def run(&block)
  @block = block
  Thread.abort_on_exception = true
  threads = ThreadGroup.new
  config.pool_size.times do
    threads.add spawn_thread
  end

  sleep
end

Protected Instance Methods

config() click to toggle source
# File lib/crap_server/thread_pool.rb, line 27
def config
  CrapServer::Application.send(:config)
end
spawn_thread() click to toggle source
# File lib/crap_server/thread_pool.rb, line 20
def spawn_thread
  Thread.new {
    handler = CrapServer::ConnectionHandler.new @sockets
    handler.handle &@block
  }
end