Interface ResourceRequest

    • Method Detail

      • request

        long request​(long amount,
                     ResourceId id)
        Request or release amount units of the resource. The absolute value of the argument is the number of resource units. It is positive to request resources or negative to release them. Zero is a no-op.

        The return value is the number of units allocated or released.

        If 0, no resources were allocated at the current time.

        If the amount is positive and the return value is less than the amount requested, only that amount was available or allocated. If the return value is greater than the amount requested, that amount is allocated and the caller should not request more until the amount is exhausted or the excess is released. If the entire amount allocated is not used any remainder should be released using request( - (amount_to_free) ) .

        If the amount is negative, the resource is being released.

        Parameters:
        amount - the number of resource units to request (amount > 0) or release (amount < 0).
        id - the ResourceId for the resource instance
        Returns:
        the number of resource units allocated or released
        Throws:
        IllegalStateException - if the ResourceRequest is not in a valid state
        ResourceRequestDeniedException - if the request should be denied