Class BlockingControl

java.lang.Object
com.nomagic.magicreport.engine.BlockingControl

@OpenApiAll public class BlockingControl extends Object
A control that supports operations that wait for the tasks done then release the lock to process.
Since:
Nov 14, 2008
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a control.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    expandPermits(int permit)
    Reduce the number of available permits by the indicated reduction.
    void
    lock(int permit)
    Acquires a permit from this control, blocking until available, or the thread is interrupted.
    void
    reducePermits(int permit)
    Expand the number of available permits.
    int
    Returns the current number of permits remaining in this control.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BlockingControl

      public BlockingControl()
      Creates a control.
  • Method Details

    • lock

      public void lock(int permit) throws InterruptedException
      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.