1
0
Fork 0
mirror of https://github.com/mperham/connection_pool synced 2023-03-27 23:22:21 -04:00

Make TimedQueue use pop/push for better performance.

This commit is contained in:
Damian Janowski 2012-12-18 14:24:54 -03:00
parent 5053b327f1
commit 3efb57b140

View file

@ -10,7 +10,7 @@ class TimedQueue
def push(obj)
@mutex.synchronize do
@que.unshift obj
@que.push obj
@resource.broadcast
end
end
@ -20,7 +20,7 @@ class TimedQueue
deadline = Time.now + timeout
@mutex.synchronize do
loop do
return @que.shift unless @que.empty?
return @que.pop unless @que.empty?
to_wait = deadline - Time.now
raise Timeout::Error, "Waited #{timeout} sec" if to_wait <= 0
@resource.wait(@mutex, to_wait)