/** * {@inheritDoc} */ public PoolAccessor createPoolAccessor(PoolParticipant participant, SizeOfEngine sizeOfEngine) { AtomicPoolAccessor accessor = new AtomicPoolAccessor(this, participant, sizeOfEngine, 0); registerPoolAccessor(accessor); return accessor; } }
/** * {@inheritDoc} */ public long delete(long sizeOf) throws IllegalArgumentException { checkLinked(); // if (sizeOf < 0L) { // throw new IllegalArgumentException("cannot delete negative size"); // } size.addAndGet(-sizeOf); return sizeOf; }
/** * {@inheritDoc} */ protected long add(long sizeOf, boolean force) throws IllegalArgumentException { if (sizeOf < 0L) { throw new IllegalArgumentException("cannot add negative size"); } long newSize = getPool().getSize() + sizeOf; if (newSize <= getPool().getMaxSize()) { // there is enough room => add & approve size.addAndGet(sizeOf); return sizeOf; } else { // check that the element isn't too big if (!force && sizeOf > getPool().getMaxSize()) { // this is too big to fit in the pool return -1; } // if there is not enough room => evict long missingSize = newSize - getPool().getMaxSize(); if (getPool().getEvictor().freeSpace(getPool().getPoolAccessors(), missingSize) || force) { size.addAndGet(sizeOf); return sizeOf; } else { // cannot free enough bytes return -1; } } }
/** * {@inheritDoc} */ public long delete(long sizeOf) { checkLinked(); size.addAndGet(-sizeOf); return sizeOf; }
/** * {@inheritDoc} */ public PoolAccessor createPoolAccessor(PoolableStore store, SizeOfEngine sizeOfEngine) { AtomicPoolAccessor accessor = new AtomicPoolAccessor(this, store, sizeOfEngine, 0); registerPoolAccessor(accessor); return accessor; } }
/** * {@inheritDoc} */ public long delete(long sizeOf) throws IllegalArgumentException { checkLinked(); // if (sizeOf < 0L) { // throw new IllegalArgumentException("cannot delete negative size"); // } size.addAndGet(-sizeOf); return sizeOf; }
/** * {@inheritDoc} */ public PoolAccessor createPoolAccessor(PoolParticipant participant, SizeOfEngine sizeOfEngine) { AtomicPoolAccessor accessor = new AtomicPoolAccessor(this, participant, sizeOfEngine, 0); registerPoolAccessor(accessor); return accessor; } }
/** * {@inheritDoc} */ public long delete(long sizeOf) throws IllegalArgumentException { checkLinked(); // if (sizeOf < 0L) { // throw new IllegalArgumentException("cannot delete negative size"); // } size.addAndGet(-sizeOf); return sizeOf; }
/** * {@inheritDoc} */ public PoolAccessor createPoolAccessor(PoolParticipant participant, SizeOfEngine sizeOfEngine) { AtomicPoolAccessor accessor = new AtomicPoolAccessor(this, participant, sizeOfEngine, 0); registerPoolAccessor(accessor); return accessor; } }
/** * {@inheritDoc} */ protected long add(long sizeOf, boolean force) { long newSize = getPool().getSize() + sizeOf; if (newSize <= getPool().getMaxSize()) { // there is enough room => add & approve size.addAndGet(sizeOf); return sizeOf; } else { // check that the element isn't too big if (!force && sizeOf > getPool().getMaxSize()) { // this is too big to fit in the pool return -1; } // if there is not enough room => evict long missingSize = newSize - getPool().getMaxSize(); if (getPool().getEvictor().freeSpace(getPool().getPoolableStores(), missingSize) || force) { size.addAndGet(sizeOf); return sizeOf; } else { // cannot free enough bytes return -1; } } }
/** * {@inheritDoc} */ protected long add(long sizeOf, boolean force) throws IllegalArgumentException { if (sizeOf < 0L) { throw new IllegalArgumentException("cannot add negative size"); } long newSize = getPool().getSize() + sizeOf; if (newSize <= getPool().getMaxSize()) { // there is enough room => add & approve size.addAndGet(sizeOf); return sizeOf; } else { // check that the element isn't too big if (!force && sizeOf > getPool().getMaxSize()) { // this is too big to fit in the pool return -1; } // if there is not enough room => evict long missingSize = newSize - getPool().getMaxSize(); if (getPool().getEvictor().freeSpace(getPool().getPoolAccessors(), missingSize) || force) { size.addAndGet(sizeOf); return sizeOf; } else { // cannot free enough bytes return -1; } } }
/** * {@inheritDoc} */ protected long add(long sizeOf, boolean force) throws IllegalArgumentException { if (sizeOf < 0L) { throw new IllegalArgumentException("cannot add negative size"); } long newSize = getPool().getSize() + sizeOf; if (newSize <= getPool().getMaxSize()) { // there is enough room => add & approve size.addAndGet(sizeOf); return sizeOf; } else { // check that the element isn't too big if (!force && sizeOf > getPool().getMaxSize()) { // this is too big to fit in the pool return -1; } // if there is not enough room => evict long missingSize = newSize - getPool().getMaxSize(); if (getPool().getEvictor().freeSpace(getPool().getPoolAccessors(), missingSize) || force) { size.addAndGet(sizeOf); return sizeOf; } else { // cannot free enough bytes return -1; } } }