From e80981e0c5b33f69e8c99a8909f6fce16891ccea Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Tue, 1 Apr 2014 03:42:56 +0200 Subject: [PATCH] add SyncPool.clear() --- vtm/src/org/oscim/utils/pool/SyncPool.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vtm/src/org/oscim/utils/pool/SyncPool.java b/vtm/src/org/oscim/utils/pool/SyncPool.java index 4a704d10..56e69b60 100644 --- a/vtm/src/org/oscim/utils/pool/SyncPool.java +++ b/vtm/src/org/oscim/utils/pool/SyncPool.java @@ -18,6 +18,7 @@ package org.oscim.utils.pool; import javax.annotation.CheckReturnValue; +@SuppressWarnings({ "rawtypes", "unchecked" }) public abstract class SyncPool> { protected final int mMaxFill; protected final boolean mClearItems; @@ -50,6 +51,13 @@ public abstract class SyncPool> { mPool = null; } + public synchronized void clear() { + while (mPool != null) { + freeItem(mPool); + mPool = (T) mPool.next; + } + } + /** * @param item * set initial state @@ -81,7 +89,6 @@ public abstract class SyncPool> { * Usage item = pool.release(item), to ensure to not keep a reference to * item! */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @CheckReturnValue public T release(T item) { if (item == null) @@ -111,7 +118,6 @@ public abstract class SyncPool> { * Usage list = pool.releaseAll(list), to ensure to not keep a reference to * list! */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue public T releaseAll(T item) { if (item == null) @@ -156,7 +162,6 @@ public abstract class SyncPool> { * * @return the item */ - @SuppressWarnings("unchecked") public T get() { synchronized (this) {