Class TaskScheduler

java.lang.Object
io.github.thecsdev.tcdcommons.api.util.thread.TaskScheduler

public final class TaskScheduler extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    cancelPeriodicCacheCleanup(com.google.common.cache.Cache<?,?> cache)
    If you have scheduled a task to periodically clean up a Cache object, you can cancel that task here.
    static void
    executeOnce(net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, BooleanSupplier condition, Runnable command)
    Schedules a task to be executed on the ReentrantThreadExecutor once a given condition is met, aka once the BooleanSupplier returns true.
    static <K, V> com.google.common.cache.Cache<K,V>
    schedulePeriodicCacheCleanup(com.google.common.cache.Cache<K,V> cache)
    Schedules a task that periodically cleans up a Cache object.
    static void
    scheduleTask(net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, long delay, TimeUnit unit, Runnable command)
    Schedules a task to be executed on the ReentrantThreadExecutor some time in the future.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • schedulePeriodicCacheCleanup

      public static <K, V> com.google.common.cache.Cache<K,V> schedulePeriodicCacheCleanup(com.google.common.cache.Cache<K,V> cache) throws NullPointerException
      Schedules a task that periodically cleans up a Cache object.
      Parameters:
      cache - The Cache object to start cleaning up periodically.
      Returns:
      The Cache object that was passed as the argument.
      Throws:
      NullPointerException - If the argument is null.
      See Also:
    • cancelPeriodicCacheCleanup

      public static void cancelPeriodicCacheCleanup(com.google.common.cache.Cache<?,?> cache)
      If you have scheduled a task to periodically clean up a Cache object, you can cancel that task here.
      Parameters:
      cache - The Cache object to stop cleaning up periodically.
      See Also:
    • scheduleTask

      public static void scheduleTask(net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, long delay, TimeUnit unit, Runnable command) throws NullPointerException
      Schedules a task to be executed on the ReentrantThreadExecutor some time in the future.
      Throws:
      NullPointerException
    • executeOnce

      @Experimental public static void executeOnce(net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, BooleanSupplier condition, Runnable command) throws NullPointerException
      Schedules a task to be executed on the ReentrantThreadExecutor once a given condition is met, aka once the BooleanSupplier returns true. Once the task is executed, it will never be executed again.
      Throws:
      NullPointerException