Interface ResourceLimits.Limit

    • Method Detail

      • limit

        long limit()
        Returns:
        total amount of permits represented by this ResourceLimits.Limit - the capacity
      • setLimit

        long setLimit​(long newLimit)
        Sets the total amount of permits represented by this ResourceLimits.Limit - the capacity If the old limit has been reached and the new limit is large enough to allow for more permits to be acquired, subsequent calls to allocate(long) or tryAllocate(long) will succeed. If the new limit is lower than the current amount of allocated permits then subsequent calls to allocate(long) or tryAllocate(long) will block or fail respectively.
        Returns:
        the old limit
      • remaining

        long remaining()
        Returns:
        remaining, unallocated permit amount
      • using

        long using()
        Returns:
        amount of permits currently in use
      • tryAllocate

        boolean tryAllocate​(long amount)
        Attempts to allocate an amount of permits from this limit. If allocated, MUST eventually be released back with release(long).
        Returns:
        true if the allocation was successful, false otherwise
      • allocate

        void allocate​(long amount)
        Allocates an amount independent of permits available from this limit. MUST eventually be released back with release(long).
      • release

        ResourceLimits.Outcome release​(long amount)
        Parameters:
        amount - return the amount of permits back to this limit
        Returns:
        ABOVE_LIMIT if there aren't enough permits available even after the release, or BELOW_LIMIT if there are enough permits available after the releaese.