diff --git a/Dorkbox-Util/src/dorkbox/util/bytes/ByteBuffer2Poolable.java b/Dorkbox-Util/src/dorkbox/util/bytes/ByteBuffer2Poolable.java index 509bc74..7796c66 100644 --- a/Dorkbox-Util/src/dorkbox/util/bytes/ByteBuffer2Poolable.java +++ b/Dorkbox-Util/src/dorkbox/util/bytes/ByteBuffer2Poolable.java @@ -22,14 +22,5 @@ public class ByteBuffer2Poolable implements PoolableObject { public ByteBuffer2 create() { return new ByteBuffer2(8, -1); } - - @Override - public void activate(ByteBuffer2 object) { - object.clear(); - } - - @Override - public void passivate(ByteBuffer2 object) { - } } diff --git a/Dorkbox-Util/src/dorkbox/util/objectPool/FastObjectPool.java b/Dorkbox-Util/src/dorkbox/util/objectPool/FastObjectPool.java index 3a3de27..fb7d94a 100644 --- a/Dorkbox-Util/src/dorkbox/util/objectPool/FastObjectPool.java +++ b/Dorkbox-Util/src/dorkbox/util/objectPool/FastObjectPool.java @@ -30,7 +30,6 @@ class FastObjectPool implements ObjectPool { private static final boolean USED = false; private final ObjectPoolHolder[] objects; - private final PoolableObject poolableObject; private volatile int takePointer; private volatile int releasePointer; @@ -45,7 +44,6 @@ class FastObjectPool implements ObjectPool { FastObjectPool(PoolableObject poolableObject, int size) { - this.poolableObject = poolableObject; int newSize = 1; while (newSize < size) { newSize = newSize << 1; @@ -76,7 +74,6 @@ class FastObjectPool implements ObjectPool { ObjectPoolHolder localObject = this.localValue.get(); if (localObject != null) { if (localObject.state.compareAndSet(FREE, USED)) { - this.poolableObject.activate(localObject.getValue()); return localObject; } } @@ -95,7 +92,6 @@ class FastObjectPool implements ObjectPool { // as they might have one sitting on the cache if (holder.state.compareAndSet(FREE, USED)) { this.localValue.set(holder); - this.poolableObject.activate(holder.getValue()); return holder; } } @@ -115,7 +111,6 @@ class FastObjectPool implements ObjectPool { if (object.state.compareAndSet(USED, FREE)) { Sys.unsafe.putOrderedObject(this.objects, index, object); this.releasePointer = localValue+1; - this.poolableObject.passivate(object.getValue()); } else { throw new IllegalArgumentException("Invalid reference passed"); diff --git a/Dorkbox-Util/src/dorkbox/util/objectPool/PoolableObject.java b/Dorkbox-Util/src/dorkbox/util/objectPool/PoolableObject.java index 019e936..1ba76d6 100644 --- a/Dorkbox-Util/src/dorkbox/util/objectPool/PoolableObject.java +++ b/Dorkbox-Util/src/dorkbox/util/objectPool/PoolableObject.java @@ -20,14 +20,4 @@ public interface PoolableObject { * called when a new instance is created */ public T create(); - - /** - * invoked on every instance that is borrowed from the pool - */ - public void activate(T object); - - /** - * invoked on every instance that is returned to the pool - */ - public void passivate(T object); } diff --git a/Dorkbox-Util/src/dorkbox/util/objectPool/SlowObjectPool.java b/Dorkbox-Util/src/dorkbox/util/objectPool/SlowObjectPool.java index fad7194..329d372 100644 --- a/Dorkbox-Util/src/dorkbox/util/objectPool/SlowObjectPool.java +++ b/Dorkbox-Util/src/dorkbox/util/objectPool/SlowObjectPool.java @@ -29,7 +29,6 @@ class SlowObjectPool implements ObjectPool { private final LinkedBlockingDeque> queue; - private final PoolableObject poolableObject; private ThreadLocal> localValue = new ThreadLocal<>(); @@ -37,7 +36,6 @@ class SlowObjectPool implements ObjectPool { this.queue = new LinkedBlockingDeque>(size); - this.poolableObject = poolableObject; for (int x=0;x(poolableObject.create())); } @@ -49,7 +47,6 @@ class SlowObjectPool implements ObjectPool { ObjectPoolHolder localObject = this.localValue.get(); if (localObject != null) { if (localObject.state.compareAndSet(FREE, USED)) { - this.poolableObject.activate(localObject.getValue()); return localObject; } } @@ -64,7 +61,6 @@ class SlowObjectPool implements ObjectPool { // as they might have one sitting on the cache if (holder.state.compareAndSet(FREE, USED)) { this.localValue.set(holder); - this.poolableObject.activate(holder.getValue()); return holder; } else { // put it back into the queue @@ -77,7 +73,6 @@ class SlowObjectPool implements ObjectPool { public void release(ObjectPoolHolder object) { if (object.state.compareAndSet(USED, FREE)) { this.queue.offer(object); - this.poolableObject.passivate(object.getValue()); } else { throw new IllegalArgumentException("Invalid reference passed");