code: func (p *FlushPolicyImpl) findLargestNonPendingWriter(control *DocumentsWriterFlushControl,
  	perThreadState *ThreadState) *ThreadState {
  	assert(perThreadState.dwpt.numDocsInRAM > 0)
  	maxRamSoFar := perThreadState.bytesUsed
  	// the dwpt which needs to be flushed eventually
  	maxRamUsingThreadState := perThreadState
  	assert2(!perThreadState.flushPending, "DWPT should have flushed")
  	count := 0
  	control.perThreadPool.foreach(func(next *ThreadState) {
  		if !next.flushPending {
  			if nextRam := next.bytesUsed; nextRam > 0 && next.dwpt.numDocsInRAM > 0 {
  				if p.infoStream.IsEnabled("FP") {
  					p.infoStream.Message("FP", "thread state has %v bytes; docInRAM=%v",
  						nextRam, next.dwpt.numDocsInRAM)
  				}
  				count++
  				if nextRam > maxRamSoFar {
  					maxRamSoFar = nextRam
  					maxRamUsingThreadState = next
  				}
  			}
  		}
  	})
  	if p.infoStream.IsEnabled("FP") {
  		p.infoStream.Message("FP", "%v in-use non-flusing threads states", count)
  	}
  	p.message("set largest ram consuming thread pending on lower watermark")
  	return maxRamUsingThreadState
  }
docs: /*
  Returns the current most RAM consuming non-pending ThreadState with
  at least one indexed document.
  
  This method will never return nil
  */