pop(non_block=false)
public
Retrieves data from the queue. If the queue is empty, the calling thread
is suspended until data is pushed onto the queue. If non_block is
true, the thread isn’t suspended, and an exception is raised.
Show source
def pop(non_block=false)
@mutex.synchronize{
while true
if @que.empty?
raise ThreadError, "queue empty" if non_block
@waiting.push Thread.current
@mutex.sleep
else
return @que.shift
end
end
}
end