Package monero.common
Class TaskLooper
java.lang.Object
monero.common.TaskLooper
Run a task in a fixed period loop.
-
Constructor Summary
ConstructorsConstructorDescriptionTaskLooper(Runnable task) Build the looper with a task to invoke on a fixed period loop. -
Method Summary
Modifier and TypeMethodDescriptiongetTask()Get the runnable task to invoke on a fixed period loop.booleanIndicates if looping.voidsetPeriodInMs(long periodInMs) Set the loop period in milliseconds.start(long periodInMs) Start the task loop.start(long periodInMs, boolean targetFixedPeriod) Start the task loop.voidstop()Stop the task loop.
-
Constructor Details
-
TaskLooper
Build the looper with a task to invoke on a fixed period loop.- Parameters:
task- is the task to invoke
-
-
Method Details
-
getTask
Get the runnable task to invoke on a fixed period loop.- Returns:
- the runnable task
-
start
Start the task loop.- Parameters:
periodInMs- the loop period in milliseconds- Returns:
- this instance for chaining
-
start
Start the task loop.- Parameters:
periodInMs- the loop period in millisecondstargetFixedPeriod- specifies if the task should target a fixed period by accounting for run time- Returns:
- this instance for chaining
-
isStarted
public boolean isStarted()Indicates if looping.- Returns:
- true if looping, false otherwise
-
stop
public void stop()Stop the task loop. -
setPeriodInMs
public void setPeriodInMs(long periodInMs) Set the loop period in milliseconds.- Parameters:
periodInMs- the loop period in milliseconds
-