Package com.codingchili.core.context
Class TimerSource
java.lang.Object
com.codingchili.core.context.TimerSource
Provides a method to get a timer interval that may change
after retrieving it.
-
Method Summary
Modifier and TypeMethodDescriptionintgetMS()getName()booleanisPaused()booleanstatic TimerSourceof(int ms)static TimerSourcestatic TimerSourcevoidpause()the timer will continue to tick but the scheduled operation will not be executed.setMS(int ms)setProvider(Supplier<Integer> provider)voidTerminates the timer source instance, this timer can not be started again.voidunpause()un-pauses the timersource, the timer operation will now be invoked at each interval again.
-
Method Details
-
of
-
of
- Parameters:
ms- in milliseconds of the timer period.- Returns:
- a new timer source with the given period
-
of
- 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
- Parameters:
name- the name of the timersource.- Returns:
- fluent
-
setPeriod
- Parameters:
value- an value of the given unit.unit- the unit which the value represents.- Returns:
- fluent
-
setMS
- Parameters:
ms- the time period in milliseconds to set.- Returns:
- fluent
-
getMS
public int getMS()- Returns:
- Returns the interval length in MS.
-
setProvider
- Parameters:
provider- another dynamic source of timing, configuration etc.- Returns:
- fluent
-
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.
-