/** * Return the number of instances currently idle in this pool. * * @return the number of instances currently idle in this pool */ @Override public synchronized int getNumIdle() { return _pool.size(); }
/** * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool. * * @param key the key to query * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool */ @Override public synchronized int getNumIdle(Object key) { final ObjectQueue pool = (_poolMap.get(key)); return pool != null ? pool.queue.size() : 0; }
/** * Returns the number of tests to be performed in an Evictor run, * based on the current value of <code>numTestsPerEvictionRun</code> * and the number of idle instances in the pool. * * @see #setNumTestsPerEvictionRun * @return the number of tests for the Evictor to run */ private int getNumTests() { if(_numTestsPerEvictionRun >= 0) { return Math.min(_numTestsPerEvictionRun, _pool.size()); } else { return(int)(Math.ceil(_pool.size()/Math.abs((double)_numTestsPerEvictionRun))); } }
@Override public int size() { checkForComod(); return super.size(); }
/** * Clears the specified pool, removing all pooled instances corresponding to the given <code>key</code>. * * @param key the key to clear */ @Override public void clear(K key) { Map<K, List<ObjectTimestampPair<V>>> toDestroy = new HashMap<K , List<ObjectTimestampPair<V>>>(); final ObjectQueue pool; synchronized (this) { pool = _poolMap.remove(key); if (pool == null) { return; } else { _poolList.remove(key); } // Copy objects to new list so pool.queue can be cleared inside // the sync List<ObjectTimestampPair<V>> objects = new ArrayList<ObjectTimestampPair<V>>(); objects.addAll(pool.queue); toDestroy.put(key, objects); _totalIdle = _totalIdle - pool.queue.size(); _totalInternalProcessing = _totalInternalProcessing + pool.queue.size(); pool.queue.clear(); } destroy(toDestroy, _factory); }
/** * Resets the eviction object cursor for the given key * * @param key eviction key */ private void resetEvictionObjectCursor(Object key) { if (_evictionCursor != null) { _evictionCursor.close(); } if (_poolMap == null) { return; } ObjectQueue pool = _poolMap.get(key); if (pool != null) { CursorableLinkedList<ObjectTimestampPair<V>> queue = pool.queue; _evictionCursor = queue.cursor(_lifo ? queue.size() : 0); } }
CursorableSubList(CursorableLinkedList<E> list, int from, int to) { if(0 > from || list.size() < to) { throw new IndexOutOfBoundsException(); } else if(from > to) { throw new IllegalArgumentException(); } _list = list; if(from < list.size()) { _head.setNext(_list.getListableAt(from)); _pre = (null == _head.next()) ? null : _head.next().prev(); } else { _pre = _list.getListableAt(from-1); } if(from == to) { _head.setNext(null); _head.setPrev(null); if(to < list.size()) { _post = _list.getListableAt(to); } else { _post = null; } } else { _head.setPrev(_list.getListableAt(to-1)); _post = _head.prev().next(); } _size = to - from; _modCount = _list._modCount; }
if (_maxIdle >= 0 && (pool.queue.size() >= _maxIdle)) { shouldDestroy = true; } else if (success) {
shouldDestroy = true; } else { if((_maxIdle >= 0) && (_pool.size() >= _maxIdle)) { shouldDestroy = true; } else if(success) {
/** * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool. * * @param key the key to query * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool */ public synchronized int getNumIdle(Object key) { final ObjectQueue pool = (ObjectQueue)(_poolMap.get(key)); return pool != null ? pool.queue.size() : 0; }
/** * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool. * * @param key the key to query * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool */ @Override public synchronized int getNumIdle(Object key) { final ObjectQueue pool = (_poolMap.get(key)); return pool != null ? pool.queue.size() : 0; }
/** * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool. * * @param key the key to query * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool */ public synchronized int getNumIdle(Object key) { final ObjectQueue pool = (ObjectQueue)(_poolMap.get(key)); return pool != null ? pool.queue.size() : 0; }
/** * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool. * * @param key the key to query * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool */ public synchronized int getNumIdle(Object key) { final ObjectQueue pool = (ObjectQueue)(_poolMap.get(key)); return pool != null ? pool.queue.size() : 0; }
@Override public int size() { checkForComod(); return super.size(); }
@Override public int size() { checkForComod(); return super.size(); }
public int nextIndex() { checkForComod(); if(!hasNext()) { return size(); } return _nextIndex; }