/** * Clears this Block, and puts the internal buffer back into the object pool for recycling. * This block is invalid after calling this operation. * * @param objectPool The object pool to put the buffer back into. */ public void dispose(ObjectPool objectPool) { if (objectPool == null) { throw new AssertionError(); } this.objectPool = null; blockFile = null; if (ownsBuffer) { objectPool.put(ObjectPool.TYPE_S_BLOCK, blockSize, this); } else { bb = null; sbb = null; ib = null; lb = null; objectPool.put(ObjectPool.TYPE_BLOCK, this); } }
/** * METHOD TO DO * * @param type PARAMETER TO DO * @param key PARAMETER TO DO * @param o PARAMETER TO DO */ public void put(int type, int key, Object o) { assert refCount > 0; if ( (type == TYPE_S_BLOCK) && (key == 8192)) { put(TYPE_BLOCK_8192, o); return; } Key k = newKeyInstance(type, key); ObjectStack os = (ObjectStack) sizedObjectStacks.get(k); if (os == null) { os = newObjectStackInstance(); sizedObjectStacks.put(k, os); } else { put(TYPE_KEY, k); } os.push(o); }
avlNode.objectPool.put(ObjectPool.TYPE_AVLNODE, avlNode); avlNode.objectPool = null;
/** * Gets a pooled object of a given type and size from this pool. * * @param type The ID of the type of object to find. * @param key The size of the object to find. * @return A pooled object, or <code>null</code> if no objects are available. */ public Object get(int type, int key) { assert refCount > 0; if ( (type == TYPE_S_BLOCK) && (key == 8192)) { return get(TYPE_BLOCK_8192); } Key k = newKeyInstance(type, key); ObjectStack os = (ObjectStack) sizedObjectStacks.get(k); put(TYPE_KEY, k); if ( (os != null) && !os.isEmpty()) { return os.pop(); } if (nextPool != null) { synchronized (nextPool) { return nextPool.get(type, key); } } return null; }