Releases a given amount of capacity back to the pool, making it available
to consumers.

@param capacity capacity to release
@throws IllegalArgumentException if given capacity is negative
353227
public void release(int capacity) {
        if (capacity < 0) {
            throw new IllegalArgumentException("capacity to release cannot be negative");
        }

        // in the common 'good' case where we have our full capacity available we can
        // short circuit going any further and avoid unnecessary locking.
        if (availableCapacity >= 0 && availableCapacity != maxCapacity) {
            synchronized (lock) {
                availableCapacity = Math.min((availableCapacity + capacity), maxCapacity);
            }
        }
    }
1084628
public void releasePutFromLoadLock(Object key, Lock lock) {
		if (trace) {
			log.tracef("releasePutFromLoadLock(%s#%s, %s)", cache.getName(), key, lock);
		}
		final PendingPutMap pending = (PendingPutMap) lock;
		if ( pending != null ) {
			if ( pending.canRemove() ) {
				pending.setRemoved();
				pendingPuts.remove( key, pending );
			}
			pending.releaseLock();
		}
	}
1269153
void releaseResources(JobInstance ji)
    {
        this.peremption.remove(ji.getId());
        this.actualNbThread.decrementAndGet();

        for (ResourceManagerBase rm : this.resourceManagers)
        {
            rm.releaseResource(ji);
        }

        if (!this.strictPollingPeriod)
        {
            // Force a new loop at once. This makes queues more fluid.
            loop.release(1);
        }
        this.engine.signalEndOfRun();
    }
444277
@Override
	// @NotThreadSafe
	protected void ensureCapacity(long capacity) throws IOException {
		long curCapacity = pbuffer.capacity();
		if(curCapacity<capacity) expandCapacity(curCapacity, capacity);
	}
833347
@Override
    public void free(AllocationPoint point) {
        if (point.getAllocationStatus() == AllocationStatus.DEVICE) {
            super.free(point);
        } else {
            AllocationShape shape = point.getShape();
            long reqMemory = AllocationUtils.getRequiredMemory(shape);

            // we don't cache too big objects
            if (reqMemory > CudaEnvironment.getInstance().getConfiguration().getMaximumHostCacheableLength() || zeroCachedAmount.get() >= CudaEnvironment.getInstance().getConfiguration().getMaximumHostCache()) {
                super.free(point);
                return;
            }

            ensureCacheHolder(shape);

            /*
                Now we should decide if this object can be cached or not
             */
            CacheHolder cache = zeroCache.get(shape);

            // memory chunks < threshold will be cached no matter what
            if (reqMemory <= FORCED_CACHE_THRESHOLD) {
                Pointer.memset(point.getHostPointer(), 0, reqMemory);
                cache.put(new CudaPointer(point.getHostPointer().address()));
            } else {
                long cacheEntries = cache.size();
                long cacheHeight = zeroCache.size();

                // total memory allocated within this bucket
                long cacheDepth = cacheEntries * reqMemory;

                Pointer.memset(point.getHostPointer(), 0, reqMemory);
                cache.put(new CudaPointer(point.getHostPointer().address()));
            }

            MemoryTracker.getInstance().decrementAllocatedHostAmount(reqMemory);
            MemoryTracker.getInstance().incrementCachedHostAmount(reqMemory);
        }
    }
121078
protected void updated()
    {
        if (remaining < 0 && remaining > capacity)
        {
            throw new IllegalArgumentException(remaining+" illegal remaining at %s"+toString());
        }
        if (marked < 0 && marked > capacity)
        {
            throw new IllegalArgumentException(marked+" illegal marked at %s"+toString());
        }
    }
561059
private void reallocate(int capacity) {
    if (capacity != elements.length) {
      assert (size <= capacity);
      float[] newArray = new float[capacity];
      for (int i = 0; i < size; i++) {
        newArray[i] = elements[i];
      }
      elements = newArray;
    }
  }
913434
public void invalidate(CachedSeekableInputStream inputStream) throws IOException {
    mUnderFileInputStreamCache.invalidate(inputStream.getResourceId());
    release(inputStream);
  }
898474
public static byte[] ensureCapacity(byte array[], int capacity){
        if(capacity<=0 || capacity-array.length<=0)
            return array;

        int newCapacity = array.length*2;
        if(newCapacity-capacity< 0)
            newCapacity = capacity;
        if(newCapacity<0){
            if(capacity<0) // overflow
                throw new OutOfMemoryError();
            newCapacity = Integer.MAX_VALUE;
        }
        return Arrays.copyOf(array, newCapacity);
    }
778414
protected void releaseInstance(T instance) throws IOException {
    AtomicInteger currentCount = providedVsCount.get(instance);
    if(currentCount != null) {
      if(currentCount.decrementAndGet() < 0) {
        currentCount.incrementAndGet();
        throw new IllegalArgumentException("Given instance of " + instance.getClass().getName() + " is not managed by this provider");
      }
    } else {
      throw new IllegalArgumentException("Given instance of " + instance.getClass().getName() + " is not managed by this provider");
    }

    if(instantiated.remove(instance) && instance instanceof Closeable) {
      ((Closeable)instance).close();
    }
  }
508252
public void releaseAllChunkMemoryUsage()
  {
    if (chunks == null || chunks.size() == 0)
    {
      return;
    }

    for (int i = 0; i < chunks.size(); i++)
    {
      releaseCurrentMemoryUsage(i, chunks.get(i).computeNeededChunkMemory());
    }
  }
1035884
public synchronized void release( T poolObject )
	{
		if (closed)
			return;
		
		// Someone's waiting ?
		if (pendingWaits > 0)
		{
			available.add(poolObject);
			notifyAll();
		}
		else
		{
			// Pool is too large, destroy object
			if (available.size() >= maxIdle)
			{
				all.remove(poolObject);
				internalDestroyPoolObject(poolObject);
			}
			else
				available.add(poolObject); // Recycle object
		}
	}
1228335
protected void release()
   {
      if (tc.isEntryEnabled()) SibTr.entry(this, tc, "release");
      if (!transmissionsRemaining)
      {
         if (tc.isDebugEnabled()) SibTr.debug(this, tc, "no more transmissions remaining - repooling");
         
         // Ensure we release the byte buffers back into the pool
         if (buffer != null)
         {
            buffer.release();
         }
         
         connection = null;
         conversation = null;
         buffer = null;
         sendListener = null;
         pool.add(this);
      }
      if (tc.isEntryEnabled()) SibTr.exit(this, tc, "release");
   }
1126468
public void setStorageSize(java.util.Collection<Range> storageSize) {
        if (storageSize == null) {
            this.storageSize = null;
            return;
        }

        this.storageSize = new java.util.ArrayList<Range>(storageSize);
    }
533151
public void release() 
    { 
        if (!_hasAcquired)
            return;

        // Deliver the onRelease event to the registered listeners
        for (ResourceEvents resourceListener : _listeners)
            resourceListener.onRelease();

        // Unregister this ResourceContext with associated container context
        _containerContext.removeResourceContext(this, _bean);

        // Reset the flag to indicate resources have been released.
        _hasAcquired = false;
    }
605497
public final void ensureCapacity( int targetCapacity )
    {
        if (targetCapacity > capacity)
        {
            int newLength = Math.max(capacity << 1, targetCapacity);
            byte[] copy = new byte[newLength];
            System.arraycopy(buf, 0, copy, 0, capacity);
            buf = copy;
            capacity = newLength;
        }
    }
1187224
protected synchronized void releaseConnectionPool(String poolName) {

    HikariDataSource pool = pools.get(poolName);

    if (pool != null) {
      logger.info("Releasing pool: {}...", pool.getPoolName());
      pool.close();
    }
  }