Class OrderedTaskQueue

  • All Implemented Interfaces:
    java.lang.Runnable
    Direct Known Subclasses:
    MultiTaskQueue

    public class OrderedTaskQueue
    extends java.lang.Thread
    class to run heavy tasks one at a time
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int executing()  
      long getAvQueue()
      Getter for average time waiting
      long getAvRun()
      Getter for average time running
      static OrderedTaskQueue getCreateQueue​(java.lang.String name)
      grab the queue
      int getDone()
      number of already completed tasks
      long getSumQueue()
      Getter for sumQueue attribute.
      long getSumRun()
      Getter for sumRun attribute.
      boolean interruptCurrent​(int minAge)  
      boolean isLive()  
      boolean queue​(java.lang.Runnable task)  
      void run()  
      java.lang.String shortString()  
      void shutDown()  
      static void shutDown​(java.lang.String name)
      grab the queue
      static void shutDownAll()  
      int size()
      size of the waiting queue
      java.lang.String toString()  
      int waiting()
      size of the waiting queue + currently executing
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getCreateQueue

        public static OrderedTaskQueue getCreateQueue​(java.lang.String name)
        grab the queue
        Parameters:
        name - - must not be null
        Returns:
        the queue to fill with tasks
      • shutDown

        public static void shutDown​(java.lang.String name)
        grab the queue
        Parameters:
        name - - must not be null
      • shutDownAll

        public static void shutDownAll()
      • shutDown

        public void shutDown()
      • interruptCurrent

        public boolean interruptCurrent​(int minAge)
        Parameters:
        minAge - minimum age to interrupt
        Returns:
        true if we successfully interrupted or no entry was running; false if unsuccessful or current is younger than minAge
      • size

        public int size()
        size of the waiting queue
        Returns:
      • executing

        public int executing()
      • waiting

        public int waiting()
        size of the waiting queue + currently executing
        Returns:
      • getDone

        public int getDone()
        number of already completed tasks
        Returns:
      • isLive

        public boolean isLive()
        Returns:
      • queue

        public boolean queue​(java.lang.Runnable task)
        Parameters:
        task - the thing to send off
        Returns:
        true if successfully queued
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
        See Also:
        Thread.run()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Thread
        Returns:
        See Also:
        Thread.toString()
      • shortString

        public java.lang.String shortString()
      • getAvQueue

        public long getAvQueue()
        Getter for average time waiting
        Returns:
        the average sumQueue
      • getSumQueue

        public long getSumQueue()
        Getter for sumQueue attribute. total time waiting
        Returns:
        the sumQueue
      • getAvRun

        public long getAvRun()
        Getter for average time running
        Returns:
        the average sumRun
      • getSumRun

        public long getSumRun()
        Getter for sumRun attribute. total time running
        Returns:
        the sumRun