@Override public boolean evict(final EvictionConfig config, final PooledObject<T> underTest, final int idleCount) { if ((config.getIdleSoftEvictTime() < underTest.getIdleTimeMillis() && config.getMinIdle() < idleCount) || config.getIdleEvictTime() < underTest.getIdleTimeMillis()) { return true; } return false; } }
/** * Updates statistics after an object is borrowed from the pool. * @param p object borrowed from the pool * @param waitTime time (in milliseconds) that the borrowing thread had to wait */ final void updateStatsBorrow(final PooledObject<T> p, final long waitTime) { borrowedCount.incrementAndGet(); idleTimes.add(p.getIdleTimeMillis()); waitTimes.add(waitTime); // lock-free optimistic-locking maximum long currentMax; do { currentMax = maxBorrowWaitTimeMillis.get(); if (currentMax >= waitTime) { break; } } while (!maxBorrowWaitTimeMillis.compareAndSet(currentMax, waitTime)); }
@Override public boolean evict(final EvictionConfig config, final PooledObject<T> underTest, final int idleCount) { if ((config.getIdleSoftEvictTime() < underTest.getIdleTimeMillis() && config.getMinIdle() < idleCount) || config.getIdleEvictTime() < underTest.getIdleTimeMillis()) { return true; } return false; } }
/** * Updates statistics after an object is borrowed from the pool. * @param p object borrowed from the pool * @param waitTime time (in milliseconds) that the borrowing thread had to wait */ final void updateStatsBorrow(final PooledObject<T> p, final long waitTime) { borrowedCount.incrementAndGet(); idleTimes.add(p.getIdleTimeMillis()); waitTimes.add(waitTime); // lock-free optimistic-locking maximum long currentMax; do { currentMax = maxBorrowWaitTimeMillis.get(); if (currentMax >= waitTime) { break; } } while (!maxBorrowWaitTimeMillis.compareAndSet(currentMax, waitTime)); }