def pop(non_block=false)
      handle_interrupt do
        @mutex.synchronize do
          while true
            if @que.empty?
              if non_block
                raise ThreadError, "queue empty"
              else
                begin
                  @num_waiting += 1
                  @cond.wait @mutex
                ensure
                  @num_waiting -= 1
                end
              end
            else
              return @que.shift
            end
          end
        end
      end
    end
def pop(non_block=false)
      handle_interrupt do
        @mutex.synchronize do
          while true
            if @que.empty?
              if non_block
                raise ThreadError, "queue empty"
              else
                begin
                  @num_waiting += 1
                  @cond.wait @mutex
                ensure
                  @num_waiting -= 1
                end
              end
            else
              return @que.shift
            end
          end
        end
      end
    end
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.