Class ResizableSemaphore
- java.lang.Object
-
- java.util.concurrent.Semaphore
-
- org.forgerock.openam.shared.concurrency.ResizableSemaphore
-
- All Implemented Interfaces:
Serializable
public class ResizableSemaphore extends Semaphore
ASemaphoreimplementation which performs exactly as a standardSemaphore, but supports 'resizing' of theSemaphoretoo.- Since:
- 13.0.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ResizableSemaphore(int permits)Creates aResizableSemaphorewith the given number of permits and nonfair fairness setting.ResizableSemaphore(int permits, boolean fair)Creates aResizableSemaphorewith the given number of permits and the given fairness setting.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidincreasePermits(int increase)Increase the number of available permits by the amount in the supplied argument.protected voidreducePermits(int reduction)Overridden method to stop it being protected.-
Methods inherited from class java.util.concurrent.Semaphore
acquire, acquire, acquireUninterruptibly, acquireUninterruptibly, availablePermits, drainPermits, getQueuedThreads, getQueueLength, hasQueuedThreads, isFair, release, release, toString, tryAcquire, tryAcquire, tryAcquire, tryAcquire
-
-
-
-
Constructor Detail
-
ResizableSemaphore
public ResizableSemaphore(int permits, boolean fair)Creates aResizableSemaphorewith the given number of permits and the given fairness setting.- Parameters:
permits- the initial number of permits available. This value may be negative, in which case releases must occur before any acquires will be granted.fair-trueif this semaphore will guarantee first-in first-out granting of permits under contention, elsefalse
-
ResizableSemaphore
public ResizableSemaphore(int permits)
Creates aResizableSemaphorewith the given number of permits and nonfair fairness setting.- Parameters:
permits- the initial number of permits available. This value may be negative, in which case releases must occur before any acquires will be granted.
-
-
Method Detail
-
reducePermits
protected void reducePermits(int reduction)
Overridden method to stop it being protected. Decrease the number of available permits by the amount in the supplied argument.- Overrides:
reducePermitsin classSemaphore- Parameters:
reduction-
-
increasePermits
public void increasePermits(int increase)
Increase the number of available permits by the amount in the supplied argument.- Parameters:
increase- The number of permits to add.
-
-