- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ResourceApproverA ResourceApprover is a callback to approve resource requests. The
ResourceMeteris the source of the allocation or release. To limit the rate of consumption, the approver may delay returning but should not do so excessively. Neither locking nor synchronization is used during the call to
requestso the value of the meter may change asynchronously due to requests from other threads.
- See Also:
long request(ResourceMeter meter, long previous, long amount, ResourceId id)Requests approval to allocate or release a resource from a ResourceMeter. For allocation, an amount greater than zero, the amount is applied to the meter before the request so it is immediately visible. For releasing a resource, an amount less than zero, the amount is applied after the request to avoid premature release of the resource.
ResourceApproverwishes to deny the request it should throw a
meter- the ResourceMeter
previous- the value of the meter before the request
amount- the amount of resource being requested (positive) or released (negative)
id- the ResourceId making the request; may be null
- the amount consumed (positive) or released (negative) or zero if the request is denied
ResourceRequestDeniedException- is thrown to indicate the request must be denied.