Class TimerSource

java.lang.Object
com.codingchili.core.context.TimerSource

public class TimerSource extends Object
Provides a method to get a timer interval that may change after retrieving it.
  • Method Details

    • of

      public static TimerSource of(Supplier<Integer> ms)
    • of

      public static TimerSource of(int ms)
      Parameters:
      ms - in milliseconds of the timer period.
      Returns:
      a new timer source with the given period
    • of

      public static TimerSource of(int value, TimeUnit unit)
      Parameters:
      value - an value of the given unit.
      unit - the unit which the value represents.
      Returns:
      a new timer source with the given period
    • setName

      public TimerSource setName(String name)
      Parameters:
      name - the name of the timersource.
      Returns:
      fluent
    • setPeriod

      public TimerSource setPeriod(int value, TimeUnit unit)
      Parameters:
      value - an value of the given unit.
      unit - the unit which the value represents.
      Returns:
      fluent
    • setMS

      public TimerSource setMS(int ms)
      Parameters:
      ms - the time period in milliseconds to set.
      Returns:
      fluent
    • getMS

      public int getMS()
      Returns:
      Returns the interval length in MS.
    • setProvider

      public TimerSource setProvider(Supplier<Integer> provider)
      Parameters:
      provider - another dynamic source of timing, configuration etc.
      Returns:
      fluent
    • getName

      public String getName()
      Returns:
      the name of the timer if set otherwise the instance address.
    • pause

      public void pause()
      the timer will continue to tick but the scheduled operation will not be executed. note: has no effect if already paused.
    • unpause

      public void unpause()
      un-pauses the timersource, the timer operation will now be invoked at each interval again. note: has no effect if already unpaused.
    • isPaused

      public boolean isPaused()
      Returns:
      true if the timer source is paused.
    • terminate

      public void terminate()
      Terminates the timer source instance, this timer can not be started again.
    • isTerminated

      public boolean isTerminated()
      Returns:
      true if the timer source is terminated and the timer should be de-scheduled.