Module gomint.api

Interface Scheduler


  • public interface Scheduler
    Version:
    1.0
    Author:
    BlackyPaw
    • Method Detail

      • executeAsync

        Task executeAsync​(Runnable runnable)
        Run the runnable in another Thread
        Parameters:
        runnable - which should be executed
        Returns:
        the created and scheduled Task
      • scheduleAsync

        Task scheduleAsync​(Runnable runnable,
                           long delay,
                           TimeUnit timeUnit)
        Executes a runnable with a delay. It blocks the Thread for the time until the delay arrives
        Parameters:
        runnable - which should be executed
        delay - amount of timeUnit which should be used for waiting
        timeUnit - which should be used to multiply the delay
        Returns:
        the created and scheduled Task
      • scheduleAsync

        Task scheduleAsync​(Runnable runnable,
                           long delay,
                           long period,
                           TimeUnit timeUnit)
        Executes a runnable with a delay. It blocks the Thread for the time until the delay arrives. After the execution of the Runnable it gets rescheduled again in an infinite Loop. You can cancel the returned Task to stop that. It uses the same Thread over and over for rescheduling the Task.
        Parameters:
        runnable - which should be executed
        delay - amount of timeUnit which should be used for waiting
        period - amount of timeUnit which should be used for rescheduling the runnable
        timeUnit - which should be used to multiply the delay / period
        Returns:
        the created and scheduled Task
      • execute

        Task execute​(Runnable runnable)
        Execute the given runnable on the next tick
        Parameters:
        runnable - which should be executed
        Returns:
        the created and scheduled Task
      • schedule

        Task schedule​(Runnable runnable,
                      long delay,
                      TimeUnit timeUnit)
        Executes a runnable with a delay. The time given is not exactly taken.
        Parameters:
        runnable - which should be executed
        delay - amount of timeUnit which should be used for waiting
        timeUnit - which should be used to multiply the delay
        Returns:
        the created and scheduled Task
      • schedule

        Task schedule​(Runnable runnable,
                      long delay,
                      long period,
                      TimeUnit timeUnit)
        Executes a runnable with a delay. It gets scheduled to run on the main thread. The runnable will NOT run at the exact time you give it since running tasks is calculated by the amount of TPS a server runs. The higher the TPS the more exact are the timers in here.
        Parameters:
        runnable - which should be executed
        delay - amount of timeUnit which should be used for waiting
        period - amount of timeUnit which should be used for rescheduling the runnable
        timeUnit - which should be used to multiply the delay / period
        Returns:
        the created and scheduled Task