public class CapacityManager extends Object
Constructor | Description |
---|---|
CapacityManager(int maxCapacity) |
Creates a CapacityManager.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
acquire() |
Attempts to acquire a single capacity unit.
|
boolean |
acquire(int capacity) |
Attempts to acquire a given amount of capacity.
|
int |
availableCapacity() |
Returns the currently available capacity.
|
int |
consumedCapacity() |
Returns the currently consumed capacity.
|
void |
release() |
Releases a single unit of capacity back to the pool, making it available
to consumers.
|
void |
release(int capacity) |
Releases a given amount of capacity back to the pool, making it available
to consumers.
|
public CapacityManager(int maxCapacity)
maxCapacity
- maximum capacity of this resource.
available capacity will initially be set to this value.
if a negative value is provided the capacity manager will operate in a no-op
passthrough mode in which all acquire calls will return true.public boolean acquire()
public boolean acquire(int capacity)
capacity
- capacity to acquireIllegalArgumentException
- if given capacity is negativepublic void release()
public void release(int capacity)
capacity
- capacity to releaseIllegalArgumentException
- if given capacity is negativepublic int consumedCapacity()
public int availableCapacity()
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.