Interface Scheduler

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long getCurrentTime()
      This returns the current time for the scheduler
      long getNumTasksExecuted()
      Returns the total number of scheduled tasks (ReadyRunnables) that have been executed since the scheduler was initialized.
      int getStatus()
      Returns the current of this fiber.
      void pause()
      Pauses the scheduler if it is current running.
      void resume()
      Resumes the scheduler if it has been paused.
      void schedule​(long interval, ReadyRunnable runnable)
      schedule
      void start()
      Starts the fiber.
      void stop()
      Stops the fiber.
    • Method Detail

      • schedule

        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 ScheduleTimer
        Parameters:
        interval - a long.
        runnable - a ReadyRunnable object.
      • getCurrentTime

        long getCurrentTime()
        This returns the current time for the scheduler
        Specified by:
        getCurrentTime in interface Timer
        Returns:
        a long.
      • start

        void start()
        Starts the fiber.
        Throws:
        java.lang.IllegalStateException - Thrown if the fiber is already running.
      • stop

        void stop()
        Stops the fiber. If the fiber has never been run then an exception is generated.
        Throws:
        java.lang.IllegalStateException - Throws if the fiber has never been started.
      • pause

        void pause()
        Pauses the scheduler if it is current running. If the fiber has not been run or has already stopped then an exception is generated.
        Throws:
        java.lang.IllegalStateException - Throws if the operation could not be completed due to the fiber's state.
      • resume

        void resume()
        Resumes the scheduler if it has been paused. If the fiber has not been run or has already stopped then an exception is generated.
        Throws:
        java.lang.IllegalStateException - Throws if the operation could not be completed due to the fiber's state.
      • getStatus

        int getStatus()
        Returns the current of this fiber.
        Returns:
        The current status.
      • getNumTasksExecuted

        long getNumTasksExecuted()
        Returns the total number of scheduled tasks (ReadyRunnables) that have been executed since the scheduler was initialized.
        Returns:
        the number of task executed