Package com.nomagic.magicreport.engine
Class BlockingControl
java.lang.Object
com.nomagic.magicreport.engine.BlockingControl
A control that supports operations that wait for the tasks done then release the lock to process.
- Since:
- Nov 14, 2008
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexpandPermits(int permit) Reduce the number of available permits by the indicated reduction.voidlock(int permit) Acquires a permit from this control, blocking until available, or the thread is interrupted.voidreducePermits(int permit) Expand the number of available permits.intReturns the current number of permits remaining in this control.
-
Constructor Details
-
BlockingControl
public BlockingControl()Creates a control.
-
-
Method Details
-
lock
Acquires a permit from this control, blocking until available, or the thread is interrupted.- Parameters:
permit- the number of permits to acquire- Throws:
InterruptedException- if the current thread is interrupted
-
expandPermits
public void expandPermits(int permit) Reduce the number of available permits by the indicated reduction. The method attempts to release lock, returning them to the semaphore if there is no permits available after the request.- Parameters:
permit- the number of permits to remove
-
reducePermits
public void reducePermits(int permit) Expand the number of available permits.- Parameters:
permit- the number of permits to remove
-
remainPermits
public int remainPermits()Returns the current number of permits remaining in this control.- Returns:
- the number of permits remaining in this control.
-