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:
parent
5053b327f1
commit
3efb57b140
1 changed files with 2 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue