Project

General

Profile

Backport #2092 » queue_ruby19.patch

quix (James M. Lawrence), 09/12/2009 09:49 PM

View differences:

lib/thread.rb (working copy)
# Pushes +obj+ to the queue.
#
def push(obj)
t = nil
@mutex.synchronize{
@que.push obj
begin
......
retry
end
}
begin
t.run if t
rescue ThreadError
end
end
#
......
# thread isn't suspended, and an exception is raised.
#
def pop(non_block=false)
while true
@mutex.synchronize{
@mutex.synchronize{
while true
if @que.empty?
raise ThreadError, "queue empty" if non_block
@waiting.push Thread.current
......
else
return @que.shift
end
}
end
end
}
end
#
......
# until space becomes available.
#
def push(obj)
t = nil
@mutex.synchronize{
while true
break if @que.length < @max
......
retry
end
}
begin
t.run if t
rescue ThreadError
end
end
#
......
#
def pop(*args)
retval = super
t = nil
@mutex.synchronize {
if @que.length < @max
begin
......
end
end
}
begin
t.run if t
rescue ThreadError
end
retval
end
(2-2/3)