Class DecompilerConcurrentQ<I,​R>

  • Type Parameters:
    I - The input data needed by the supplied QCallback
    R - The result data (can be the same as I if there is no result) returned by the QCallback.process(Object, TaskMonitor) method.

    public class DecompilerConcurrentQ<I,​R>
    extends java.lang.Object
    A class to perform some of the boilerplate setup of the ConcurrentQ that is shared amongst clients that perform decompilation in parallel.

    This class can be used in a blocking or non-blocking fashion.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(I i)  
      void addAll​(java.util.Collection<I> collection)  
      void addAll​(java.util.Iterator<I> iterator)  
      void dispose()  
      void dispose​(long timeoutSeconds)
      Calls dispose on the queue being processed.
      void process​(java.util.Iterator<I> functions, java.util.function.Consumer<R> consumer)
      Adds all items to the queue for processing.
      java.util.Collection<QResult<I,​R>> waitForResults()
      Waits for all results to be delivered.
      void waitUntilDone()
      Waits for all work to finish.
      • Methods inherited from class java.lang.Object

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

      • DecompilerConcurrentQ

        public DecompilerConcurrentQ​(QCallback<I,​R> callback,
                                     java.lang.String threadPoolName,
                                     TaskMonitor monitor)
    • Method Detail

      • addAll

        public void addAll​(java.util.Collection<I> collection)
      • addAll

        public void addAll​(java.util.Iterator<I> iterator)
      • add

        public void add​(I i)
      • process

        public void process​(java.util.Iterator<I> functions,
                            java.util.function.Consumer<R> consumer)
        Adds all items to the queue for processing. The results will be passed to the given consumer as they are produced.
        Parameters:
        functions - the functions to process
        consumer - the results consumer
      • waitForResults

        public java.util.Collection<QResult<I,​R>> waitForResults()
                                                                throws java.lang.InterruptedException
        Waits for all results to be delivered. The client is responsible for processing the results and handling any exceptions that may have occurred.
        Returns:
        all results
        Throws:
        java.lang.InterruptedException - if interrupted while waiting
      • waitUntilDone

        public void waitUntilDone()
                           throws java.lang.InterruptedException,
                                  java.lang.Exception
        Waits for all work to finish. Any exception encountered will trigger all processing to stop. If you wish for the work to continue despite exceptions, then use waitForResults().
        Throws:
        java.lang.InterruptedException - if interrupted while waiting
        java.lang.Exception - any exception that is encountered while processing items.
      • dispose

        public void dispose()
      • dispose

        public void dispose​(long timeoutSeconds)
        Calls dispose on the queue being processed. Further, the call will block for up to timeoutSeconds while waiting for the queue to finish processing.
        Parameters:
        timeoutSeconds - the number of seconds to wait for the disposed queue to finish processing