Class AsyncLoader

java.lang.Object
com.netscape.certsrv.util.AsyncLoader

public class AsyncLoader extends Object
A locking mechanism for loading or reloading an initially unknown number of items. The "producer" is the thread that loads items, informing the Loader when each item is loaded and how many items there are (when that fact becomes known). Other threads can await the completion of a (re)loading process.
  • Constructor Details

    • AsyncLoader

      public AsyncLoader(int timeoutSeconds)
      Create an AsyncLoader with the specified timeout. If timeoutSeconds > 0, startLoading() will start a timer that will forcibly unlock the loader after the specified timeout.
  • Method Details

    • startLoading

      public void startLoading()
      Acquire the lock as a producer and reset progress-tracking variables.
    • increment

      public void increment()
      Increment the number of items loaded by 1. If the number of items is known and that many items have been loaded, unlock the loader. If the loader is not currently loading, does nothing.
    • setNumItems

      public void setNumItems(Integer n)
      Set the number of items. If the number of items already loaded is equal to or greater than the number, unlock the loader.
    • awaitLoadDone

      public void awaitLoadDone() throws InterruptedException
      Wait upon the consumer to finish loading items.
      Throws:
      InterruptedException - if the thread is interrupted while waiting for the loading lock. This can happen due to timeout.
    • shutdown

      public void shutdown()