Class LegacyScheduler

    • Constructor Summary

      Constructors 
      Constructor Description
      LegacyScheduler​(java.lang.String parent, int maxSize)
      Constructs a new instance of the scheduler.
      LegacyScheduler​(java.lang.String parent, int maxSize, float lowMark, float hiMark)
      Constructs a new instance of the scheduler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getCurrentTime()
      getCurrentTime
      java.lang.String getName()
      Returns the name of this fiber.
      long getNumTasksExecuted()
      Returns the total number of scheduled tasks (ReadyRunnables) that have been executed since the scheduler was initialized.
      java.util.concurrent.ExecutorService getRunner()
      Returns the pool of threads that are used to executed the runnable instances scheduled by the class' instance.
      int getScheduled()
      Returns total number of elements currently scheduled.
      int getStatus()
      getStatus
      void pause()
      pause
      void resume()
      resume
      void run()
      The main method of the scheduler.
      void schedule​(long interval, ReadyRunnable runnable)
      schedule
      void schedule​(ReadyRunnable runnable, long interval)
      This method is used to schedule a ready runnable in the system.
      void start()
      start
      void stop()
      stop
      • Methods inherited from class java.lang.Object

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

      • LegacyScheduler

        public LegacyScheduler​(java.lang.String parent,
                               int maxSize)
        Constructs a new instance of the scheduler. The maximum number of executable threads is specified in the constructor. The executable threads are part of a runnable thread pool where the scheduled runnables are executed.
        Parameters:
        parent - String prepended to "Scheduler" to create fiber name
        maxSize - The maximum size of the thread pool.
      • LegacyScheduler

        public LegacyScheduler​(java.lang.String parent,
                               int maxSize,
                               float lowMark,
                               float hiMark)
        Constructs a new instance of the scheduler. The maximum number of executable threads is specified in the constructor. The executable threads are part of a runnable thread pool where the scheduled runnables are executed.
        Parameters:
        parent - String prepended to "Scheduler" to create fiber name
        maxSize - The maximum size of the thread pool.
        lowMark - The low water mark ratios of thread size to threads when threads are stopped.
        hiMark - The high water mark ratio of thread size to threads when threads are started.
    • Method Detail

      • schedule

        public void schedule​(ReadyRunnable runnable,
                             long interval)
        This method is used to schedule a ready runnable in the system. The interval is used as the key for determining which queue to add the runnable.
        Parameters:
        runnable - The element to run when interval expires.
        interval - The queue to add the runnable to.
        Throws:
        java.lang.RuntimeException - Thrown if an error occurs adding the element to the queue.
      • schedule

        public void schedule​(long interval,
                             ReadyRunnable runnable)

        schedule

        This method is used to schedule a ready runnable in the system. The interval is used as the key for determining which queue to add the runnable.
        Specified by:
        schedule in interface Scheduler
        Specified by:
        schedule in interface ScheduleTimer
        Parameters:
        interval - a long.
        runnable - a ReadyRunnable object.
      • start

        public void start()

        start

        Specified by:
        start in interface Fiber
        Specified by:
        start in interface Scheduler
      • stop

        public void stop()

        stop

        Specified by:
        stop in interface Fiber
        Specified by:
        stop in interface Scheduler
      • getName

        public java.lang.String getName()
        Returns the name of this fiber.
        Specified by:
        getName in interface Fiber
        Returns:
        a String object.
      • getScheduled

        public int getScheduled()
        Returns total number of elements currently scheduled.
        Returns:
        the sum of all the elements in the various queues
      • getRunner

        public java.util.concurrent.ExecutorService getRunner()
        Returns the pool of threads that are used to executed the runnable instances scheduled by the class' instance.
        Returns:
        thread pool
      • run

        public void run()
        The main method of the scheduler. This method is responsible for checking the runnable queues for ready objects and then enqueuing them into the thread pool for execution.
        Specified by:
        run in interface java.lang.Runnable
      • getNumTasksExecuted

        public long getNumTasksExecuted()
        Returns the total number of scheduled tasks (ReadyRunnables) that have been executed since the scheduler was initialized.
        Specified by:
        getNumTasksExecuted in interface Scheduler
        Returns:
        the number of task executed