question: long cleanup ( long now ) { int inUseConnectionCount = 0 ; int idleConnectionCount = 0 ; RealConnection longestIdleConnection = null ; long longestIdleDurationNs = Long . MIN_VALUE ; synchronized ( this ) { for ( Iterator < RealConnection > i = connections . iterator ( ) ; i . hasNext ( ) ; ) { RealConnection connection = i . next ( ) ; if ( pruneAndGetAllocationCount ( connection , now ) > 0 ) { inUseConnectionCount ++ ; continue ; } idleConnectionCount ++ ; long idleDurationNs = now - connection . idleAtNanos ; if ( idleDurationNs > longestIdleDurationNs ) { longestIdleDurationNs = idleDurationNs ; longestIdleConnection = connection ; } } if ( longestIdleDurationNs >= this . keepAliveDurationNs || idleConnectionCount > this . maxIdleConnections ) { connections . remove ( longestIdleConnection ) ; } else if ( idleConnectionCount > 0 ) { return keepAliveDurationNs - longestIdleDurationNs ; } else if ( inUseConnectionCount > 0 ) { return keepAliveDurationNs ; } else { cleanupRunning = false ; return - 1 ; } } closeQuietly ( longestIdleConnection . socket ( ) ) ; return 0 ; }
target:  Performs maintenance on this pool, evicting the connection that has been idle the longest if either it has exceeded the keep alive limit or the idle connections limit. <p>Returns the duration in nanos to sleep until the next scheduled call to this method. Returns -1 if no further cleanups are required.