Class: Puma::ThreadPool

### Home Classes Methods

### In Files

- lib/puma/thread_pool.rb

### Parent

Object

### Namespace

- CLASS Puma::ThreadPool::AutoTrim
- CLASS Puma::ThreadPool::Reaper

### Methods

- ::new
- #backlog

### Files

- Manifest.txt

### Class/Module Index

Quicksearch

- Puma
- Puma::App
- Puma::App::Status
- Puma::Binder
- Puma::CLI
- Puma::Client
- Puma::Cluster
- Puma::Cluster::Worker
- Puma::CommonLogger
- Puma::ConfigDefault
- Puma::Configuration
- Puma::Configuration::ConfigMiddleware
- Puma::ConnectionError
- Puma::Const
- Puma::ControlCLI
- Puma::DSL
- Puma::Delegation
- Puma::Events
- Puma::Events::DefaultFormatter
- Puma::Events::PidFormatter
- Puma::IOBuffer
- Puma::JRubyRestart
- Puma::JavaIOBuffer
- Puma::MiniSSL
- Puma::MiniSSL::Context
- Puma::MiniSSL::SSLError
- Puma::MiniSSL::Server
- Puma::MiniSSL::Socket
- Puma::NullIO
- Puma::Rack
- Puma::Rack::Builder
- Puma::Rack::Options
- Puma::Rack::URLMap
- Puma::Reactor
- Puma::Runner
- Puma::Server
- Puma::Single
- Puma::TCPLogger
- Puma::ThreadPool
- Puma::ThreadPool::AutoTrim
- Puma::ThreadPool::Reaper
- Puma::UnsupportedOption
- Puma::Util
- Puma::Util::HeaderHash
- OpenSSL
- OpenSSL::SSL
- OpenSSL::SSL::SSLServer
- Rack
- Rack::Handler
- Rack::Handler::Puma
- IO
- IO::WaitReadable
- Object
- Process
- String

No matching classes.

# Puma::ThreadPool

A simple thread pool management object.

### Attributes

clean_thread_locals[RW]
spawned[R]
trim_requested[R]

### Public Class Methods

new(min, max, *extra, &block) click to toggle source

Maintain a minimum of `min` and maximum of `max` threads in the pool.

The block passed is the work that will be performed in each thread.

    # File lib/puma/thread_pool.rb, line 14
    def initialize(min, max, *extra, &block)
      @not_empty = ConditionVariable.new
      @not_full = ConditionVariable.new
      @mutex = Mutex.new

      @todo = []

      @spawned = 0
      @waiting = 0

      @min = Integer(min)
      @max = Integer(max)
      @block = block
      @extra = extra

      @shutdown = false

      @trim_requested = 0

      @workers = []

      @auto_trim = nil
      @reaper = nil

      @mutex.synchronize do
        @min.times { spawn_thread }
      end

      @clean_thread_locals = false
    end

### Public Instance Methods

backlog() click to toggle source

How many objects have yet to be processed by the pool?

    # File lib/puma/thread_pool.rb, line 50
    def backlog
      @mutex.synchronize { @todo.size }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.