public int flush(Queue dst) {
        int cnt = used;
        dst.ensureFree(cnt);
        for (int i = 0; i < used; i++) {
            dst.buf[dst.writePos++] = buf[readPos];
            buf[readPos++] = null; // enable GC of dequeued object
            if (dst.writePos == dst.buf.length) {
                dst.writePos = 0;
            }
            if (readPos == buf.length) {
                readPos = 0;
            }
        }
        dst.used += used;
        used = 0;
        return cnt;
    }
Flush all elements currently in this queue into another
queue. Note that this will clear the queue.

@return the number of elements flushed
jrt/src/com/yahoo/jrt/Queue.java