Skip to content

Commit

Permalink
thread_pool.rb - add backlog_max
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Oct 12, 2024
1 parent 32e7ee5 commit e9e8620
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/puma/thread_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def initialize(name, options = {}, &block)
@mutex = Mutex.new

@todo = []
@backlog_max = 0

@spawned = 0
@waiting = 0
Expand Down Expand Up @@ -91,6 +92,12 @@ def backlog
with_mutex { @todo.size }
end

# The maximum size of the backlog
#
def backlog_max
with_mutex { @backlog_max }
end

# @!attribute [r] pool_capacity
def pool_capacity
waiting + (@max - spawned)
Expand Down Expand Up @@ -227,6 +234,8 @@ def <<(work)
end

@todo << work
t = @todo.size
@backlog_max = t if t > @backlog_max

if @waiting < @todo.size and @spawned < @max
spawn_thread
Expand Down

0 comments on commit e9e8620

Please sign in to comment.