public class ListeningMultiSemaphore extends Object
ListenableFuture
s for acquisition of different resource types rather
than blocking.Constructor and Description |
---|
ListeningMultiSemaphore(ResourceAmounts availableResources,
ResourceAllocationFairness fairness) |
Modifier and Type | Method and Description |
---|---|
com.google.common.util.concurrent.ListenableFuture<Unit> |
acquire(ResourceAmounts resources)
Returns the future which will be completed by the moment when resources will be acquired.
|
ResourceAmounts |
getAvailableResources() |
ResourceAmounts |
getMaximumValues() |
int |
getQueueLength() |
void |
release(ResourceAmounts resources)
Releases previously acquired resources.
|
public ListeningMultiSemaphore(ResourceAmounts availableResources, ResourceAllocationFairness fairness)
public com.google.common.util.concurrent.ListenableFuture<Unit> acquire(ResourceAmounts resources)
resources
- Resource amounts that need to be acquired. If they are higher than maximum
amounts, they will be capped to them.public void release(ResourceAmounts resources)
resources
- Resource amounts that need to be released. This argument should match one you
used during resource acquiring.public ResourceAmounts getAvailableResources()
public ResourceAmounts getMaximumValues()
public int getQueueLength()