Class MCRProcessableFactory

java.lang.Object
org.mycore.util.concurrent.processing.MCRProcessableFactory

public abstract class MCRProcessableFactory extends Object
Factory and utility methods for MCRProcessableExecutor.
Author:
Matthias Eichner
  • Constructor Details

    • MCRProcessableFactory

      public MCRProcessableFactory()
  • Method Details

    • progressableCallable

      public static Callable<Object> progressableCallable(Runnable task)
      Returns a Callable object that, when called, runs the given task and returns null. It also takes care if the task implements the MCRProgressable interface by calling the runnable implementation.
      Parameters:
      task - the task to run
      Returns:
      a callable object
      Throws:
      NullPointerException - if task null
    • newPool

      public static MCRProcessableExecutor newPool(ExecutorService delegate)
      Creates a new MCRProcessableExecutor.

      Be aware that you should shutdown the delegate with the MCRShutdownHandler by yourself. This method will not do this for you!

      If you like to have priority support you have to use a thread pool with a PriorityBlockingQueue!

      Parameters:
      delegate - the thread pool delegate
      Returns:
      a newly created thread pool
    • newPool

      public static MCRProcessableExecutor newPool(ExecutorService delegate, MCRProcessableCollection collection)
      Creates a new MCRProcessableExecutor. Each task submitted will be automatically added to the given collection and removed if complete.

      Be aware that you should shutdown the delegate with the MCRShutdownHandler by yourself. This method will not do this for you!

      If you like to have priority support you have to use a thread pool with a PriorityBlockingQueue!

      Parameters:
      delegate - the thread pool delegate
      collection - the collection which will be linked with the pool
      Returns:
      a newly created thread pool
    • newPriorityBlockingQueue

      public static PriorityBlockingQueue<Runnable> newPriorityBlockingQueue()
      Creates new PriorityBlockingQueue for runnables. Uses the MCRRunnableComperator for comparision.
      Returns:
      a new priority blocking queue