Skip to content

Commit fb4e23d

Browse files
committed
Add missing localvars. Accessing localvars is faster than accessing ivars
1 parent ca21111 commit fb4e23d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/puma/thread_pool.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ def spawn_thread
5353
@spawned += 1
5454

5555
th = Thread.new do
56-
todo = @todo
56+
todo = @todo
5757
block = @block
58+
mutex = @mutex
59+
cond = @cond
5860

5961
while true
6062
work = nil
6163

6264
continue = true
6365

64-
@mutex.synchronize do
66+
mutex.synchronize do
6567
while todo.empty?
6668
if @trim_requested > 0
6769
@trim_requested -= 1
@@ -75,7 +77,7 @@ def spawn_thread
7577
end
7678

7779
@waiting += 1
78-
@cond.wait @mutex
80+
cond.wait mutex
7981
@waiting -= 1
8082

8183
if @shutdown
@@ -92,7 +94,7 @@ def spawn_thread
9294
block.call work
9395
end
9496

95-
@mutex.synchronize do
97+
mutex.synchronize do
9698
@spawned -= 1
9799
@workers.delete th
98100
end

0 commit comments

Comments
 (0)