if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { // Need to reset Key cursor resetEvictionKeyCursor(); if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { continue; // reset failed, do nothing _evictionCursor.previous() : _evictionCursor.next(); _evictionCursor.remove();
/** * Informs all of my registered cursors that they are now * invalid. */ protected void invalidateCursors() { Iterator<WeakReference<Cursor>> it = _cursors.iterator(); while (it.hasNext()) { WeakReference<Cursor> ref = it.next(); Cursor cursor = ref.get(); if (cursor != null) { // cursor is null if object has been garbage-collected cursor.invalidate(); ref.clear(); } it.remove(); } }
if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { // Need to reset Key cursor resetEvictionKeyCursor(); if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { continue; // reset failed, do nothing (ObjectTimestampPair) _evictionCursor.previous() : (ObjectTimestampPair) _evictionCursor.next(); _evictionCursor.remove();
if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { // Need to reset Key cursor resetEvictionKeyCursor(); if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { continue; // reset failed, do nothing (ObjectTimestampPair) _evictionCursor.previous() : (ObjectTimestampPair) _evictionCursor.next(); _evictionCursor.remove();
if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { // Need to reset Key cursor resetEvictionKeyCursor(); if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { continue; // reset failed, do nothing (ObjectTimestampPair) _evictionCursor.previous() : (ObjectTimestampPair) _evictionCursor.next(); boolean removeObject=false;
if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { // Need to reset Key cursor resetEvictionKeyCursor(); if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { continue; // reset failed, do nothing _evictionCursor.previous() : _evictionCursor.next(); _evictionCursor.remove();
if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); } else { // Need to reset Key cursor resetEvictionKeyCursor(); if (_evictionKeyCursor != null) { if (_evictionKeyCursor.hasNext()) { key = _evictionKeyCursor.next(); resetEvictionObjectCursor(key); if ((_lifo && !_evictionCursor.hasPrevious()) || (!_lifo && !_evictionCursor.hasNext())) { continue; // reset failed, do nothing _evictionCursor.previous() : _evictionCursor.next(); _evictionCursor.remove();
final ObjectTimestampPair pair; synchronized (this) { if ((_lifo && !_evictionCursor.hasPrevious()) || !_lifo && !_evictionCursor.hasNext()) { _evictionCursor.close(); _evictionCursor = _pool.cursor(_lifo ? _pool.size() : 0); (ObjectTimestampPair) _evictionCursor.previous() : (ObjectTimestampPair) _evictionCursor.next(); _evictionCursor.remove(); _numInternalProcessing++; _evictionCursor.add(pair); if (_lifo) { _evictionCursor.previous();
final ObjectTimestampPair pair; synchronized (this) { if ((_lifo && !_evictionCursor.hasPrevious()) || !_lifo && !_evictionCursor.hasNext()) { _evictionCursor.close(); _evictionCursor = _pool.cursor(_lifo ? _pool.size() : 0); (ObjectTimestampPair) _evictionCursor.previous() : (ObjectTimestampPair) _evictionCursor.next(); _evictionCursor.remove(); _numInternalProcessing++; _evictionCursor.add(pair); if (_lifo) { _evictionCursor.previous();
final ObjectTimestampPair<T> pair; synchronized (this) { if ((_lifo && !_evictionCursor.hasPrevious()) || !_lifo && !_evictionCursor.hasNext()) { _evictionCursor.close(); _evictionCursor = _pool.cursor(_lifo ? _pool.size() : 0); _evictionCursor.previous() : _evictionCursor.next(); _evictionCursor.remove(); _numInternalProcessing++; _evictionCursor.add(pair); if (_lifo) { _evictionCursor.previous();
final ObjectTimestampPair<T> pair; synchronized (this) { if ((_lifo && !_evictionCursor.hasPrevious()) || !_lifo && !_evictionCursor.hasNext()) { _evictionCursor.close(); _evictionCursor = _pool.cursor(_lifo ? _pool.size() : 0); _evictionCursor.previous() : _evictionCursor.next(); _evictionCursor.remove(); _numInternalProcessing++; _evictionCursor.add(pair); if (_lifo) { _evictionCursor.previous();
/** * Returns a {@link ListIterator} for iterating through the * elements of this list. Unlike {@link #iterator}, a cursor * is not bothered by concurrent modifications to the * underlying list. * <p> * Specifically, when elements are added to the list before or * after the cursor, the cursor simply picks them up automatically. * When the "current" (i.e., last returned by {@link ListIterator#next} * or {@link ListIterator#previous}) element of the list is removed, * the cursor automatically adjusts to the change (invalidating the * last returned value--i.e., it cannot be removed). * <p> * Note that the returned {@link ListIterator} does not support the * {@link ListIterator#nextIndex} and {@link ListIterator#previousIndex} * methods (they throw {@link UnsupportedOperationException} when invoked. * <p> * Historical Note: In previous versions of this class, the object * returned from this method was required to be explicitly closed. This * is no longer necessary. * * @see #cursor(int) * @see #listIterator() * @see CursorableLinkedList.Cursor */ public CursorableLinkedList.Cursor cursor() { return new Cursor(0); }
/** * Returns a {@link ListIterator} for iterating through the * elements of this list. Unlike {@link #iterator}, a cursor * is not bothered by concurrent modifications to the * underlying list. * <p> * Specifically, when elements are added to the list before or * after the cursor, the cursor simply picks them up automatically. * When the "current" (i.e., last returned by {@link ListIterator#next} * or {@link ListIterator#previous}) element of the list is removed, * the cursor automatically adjusts to the change (invalidating the * last returned value--i.e., it cannot be removed). * <p> * Note that the returned {@link ListIterator} does not support the * {@link ListIterator#nextIndex} and {@link ListIterator#previousIndex} * methods (they throw {@link UnsupportedOperationException} when invoked. * <p> * Historical Note: In previous versions of this class, the object * returned from this method was required to be explicitly closed. This * is no longer necessary. * * @see #cursor(int) * @see #listIterator() * @see CursorableLinkedList.Cursor */ public CursorableLinkedList.Cursor cursor() { return new Cursor(0); }
/** * Returns a {@link ListIterator} for iterating through the * elements of this list. Unlike {@link #iterator}, a cursor * is not bothered by concurrent modifications to the * underlying list. * <p> * Specifically, when elements are added to the list before or * after the cursor, the cursor simply picks them up automatically. * When the "current" (i.e., last returned by {@link ListIterator#next} * or {@link ListIterator#previous}) element of the list is removed, * the cursor automatically adjusts to the change (invalidating the * last returned value--i.e., it cannot be removed). * <p> * Note that the returned {@link ListIterator} does not support the * {@link ListIterator#nextIndex} and {@link ListIterator#previousIndex} * methods (they throw {@link UnsupportedOperationException} when invoked. * <p> * Historical Note: In previous versions of this class, the object * returned from this method was required to be explicitly closed. This * is no longer necessary. * * @see #cursor(int) * @see #listIterator() * @see CursorableLinkedList.Cursor */ public CursorableLinkedList<E>.Cursor cursor() { return new Cursor(0); }
/** * Closes the keyed object pool. Once the pool is closed, {@link #borrowObject(Object)} * will fail with IllegalStateException, but {@link #returnObject(Object, Object)} and * {@link #invalidateObject(Object, Object)} will continue to work. This method does not * {@link #clear()} the pool. The method is idempotent - that is, it is OK to call it on a closed * pool. * * @throws Exception */ public void close() throws Exception { super.close(); synchronized (this) { clear(); if (null != _evictionCursor) { _evictionCursor.close(); _evictionCursor = null; } if (null != _evictionKeyCursor) { _evictionKeyCursor.close(); _evictionKeyCursor = null; } startEvictor(-1L); } }
/** * Returns a {@link ListIterator} for iterating through the * elements of this list. Unlike {@link #iterator}, a cursor * is not bothered by concurrent modifications to the * underlying list. * <p> * Specifically, when elements are added to the list before or * after the cursor, the cursor simply picks them up automatically. * When the "current" (i.e., last returned by {@link ListIterator#next} * or {@link ListIterator#previous}) element of the list is removed, * the cursor automatically adjusts to the change (invalidating the * last returned value--i.e., it cannot be removed). * <p> * Note that the returned {@link ListIterator} does not support the * {@link ListIterator#nextIndex} and {@link ListIterator#previousIndex} * methods (they throw {@link UnsupportedOperationException} when invoked. * <p> * Historical Note: In previous versions of this class, the object * returned from this method was required to be explicitly closed. This * is no longer necessary. * * @see #cursor(int) * @see #listIterator() * @see CursorableLinkedList.Cursor */ public CursorableLinkedList<E>.Cursor cursor() { return new Cursor(0); }
/** * Closes the keyed object pool. Once the pool is closed, {@link #borrowObject(Object)} * will fail with IllegalStateException, but {@link #returnObject(Object, Object)} and * {@link #invalidateObject(Object, Object)} will continue to work. This method does not * {@link #clear()} the pool. The method is idempotent - that is, it is OK to call it on a closed * pool. * * @throws Exception */ public void close() throws Exception { super.close(); synchronized (this) { clear(); if (null != _evictionCursor) { _evictionCursor.close(); _evictionCursor = null; } if (null != _evictionKeyCursor) { _evictionKeyCursor.close(); _evictionKeyCursor = null; } startEvictor(-1L); } }