@FunctionalInterface public interface ResourceApprover
ResourceMeter
is 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
request
so the value of the meter may change asynchronously
due to requests from other threads.NotifyingMeter
Modifier and Type | Method and Description |
---|---|
long |
request(ResourceMeter meter,
long previous,
long amount,
ResourceId id)
Requests approval to allocate or release a resource from a
ResourceMeter.
|
long request(ResourceMeter meter, long previous, long amount, ResourceId id)
If the ResourceApprover
wishes to deny the request it should
throw a ResourceRequestDeniedException
.
meter
- the ResourceMeterprevious
- the value of the meter before the requestamount
- the amount of resource being requested (positive) or
released (negative)id
- the ResourceId making the request; may be nullResourceRequestDeniedException
- is thrown to indicate the request must be denied.
Copyright © 2014, 2016, Oracle and/or its affiliates. All rights reserved.