From fb4e23d628ad77c7978b67625d0da0e5b41fd124 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 5 Jul 2012 16:05:29 -0300 Subject: [PATCH] Add missing localvars. Accessing localvars is faster than accessing ivars --- lib/puma/thread_pool.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/puma/thread_pool.rb b/lib/puma/thread_pool.rb index e71ce3d6..3d5fafb7 100644 --- a/lib/puma/thread_pool.rb +++ b/lib/puma/thread_pool.rb @@ -53,15 +53,17 @@ module Puma @spawned += 1 th = Thread.new do - todo = @todo + todo = @todo block = @block + mutex = @mutex + cond = @cond while true work = nil continue = true - @mutex.synchronize do + mutex.synchronize do while todo.empty? if @trim_requested > 0 @trim_requested -= 1 @@ -75,7 +77,7 @@ module Puma end @waiting += 1 - @cond.wait @mutex + cond.wait mutex @waiting -= 1 if @shutdown @@ -92,7 +94,7 @@ module Puma block.call work end - @mutex.synchronize do + mutex.synchronize do @spawned -= 1 @workers.delete th end