code: public long completeSegmentByteCount() {
      long result = size;
      if (result == 0) return 0;
  
      // Omit the tail if it's still writable.
      Segment tail = head.prev;
      if (tail.limit < Segment.SIZE && tail.owner) {
        result -= tail.limit - tail.pos;
      }
  
      return result;
    }
docs: Returns the number of bytes in segments that are not writable. This is the
  number of bytes that can be flushed immediately to an underlying sink
  without harming throughput.