Package org.omegazero.common.event
Class Tasks
java.lang.Object
org.omegazero.common.event.Tasks
Convenience class for globally scheduled tasks using a
TaskScheduler.
This class uses a single TaskScheduler instance, accessible through the constant I.
- Since:
- 2.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TaskSchedulerTheTaskSchedulerinstance.static final TaskSchedulerTheTaskSchedulerinstance, an alias ofI. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidQueues the givenRunnableto be run asychronously, as soon as possible.static voidQueues the givenConsumerwith the given arguments to be run asychronously, as soon as possible.static booleanclear(long id) Deprecated.static booleanDeprecated.Since 2.9.1, useIstatic voidexit()SeeTaskScheduler.exit().static TaskScheduler.TimerTaskDeprecated.Since 2.9.1, useIstatic TaskScheduler.TimerTaskDeprecated.Since 2.9.1, useIstatic voidsetErrorHandler(Consumer<Throwable> errorHandler) static TaskScheduler.TimerTaskDeprecated.Since 2.9.1, useIstatic TaskScheduler.TimerTaskDeprecated.Since 2.9.1, useI
-
Field Details
-
I
TheTaskSchedulerinstance.- Since:
- 2.9.1
- See Also:
-
TASKS
TheTaskSchedulerinstance, an alias ofI.This constant may be used instead of
Iin a static import, because it has a more descriptive name.- Since:
- 2.9.1
-
-
Method Details
-
timeout
Deprecated.Since 2.9.1, useI- Parameters:
handler- The handlertimeout- The timeout in milliseconds- Returns:
- The
TaskScheduler.TimerTaskinstance - Since:
- 2.6
-
timeout
@Deprecated public static TaskScheduler.TimerTask timeout(Consumer<Object[]> handler, long timeout, Object... args) Deprecated.Since 2.9.1, useI- Parameters:
handler- The handlertimeout- The timeout in millisecondsargs- Handler arguments- Returns:
- The
TaskScheduler.TimerTaskinstance - Since:
- 2.1
-
interval
Deprecated.Since 2.9.1, useI- Parameters:
handler- The handlertimeout- The interval in milliseconds- Returns:
- The
TaskScheduler.TimerTaskinstance - Since:
- 2.6
-
interval
@Deprecated public static TaskScheduler.TimerTask interval(Consumer<Object[]> handler, long interval, Object... args) Deprecated.Since 2.9.1, useI- Parameters:
handler- The handlerinterval- The interval in millisecondsargs- Handler arguments- Returns:
- The
TaskScheduler.TimerTaskinstance - Since:
- 2.1
-
clear
Deprecated.Since 2.9.1, useI- Parameters:
tt- TheTaskScheduler.TimerTaskto cancel- Returns:
trueif tt is notnull- Since:
- 2.1
-
clear
Deprecated.Since 2.9.1, useI- Parameters:
id- The id of theTaskScheduler.TimerTaskto cancel- Returns:
trueif the task was found and successfully canceled- Since:
- 2.1
-
async
Queues the givenRunnableto be run asychronously, as soon as possible.This method calls
TaskScheduler.timeout(Runnable, long)with a timeout value of0. Usage of this method should be kept at a minimum, since the worker threads executing handlers passed to this method are shared with other timer tasks. For more resource- or IO-intensive tasks, a dedicatedTaskQueueExecutorshould be used instead.- Parameters:
handler- The handler- Since:
- 2.11.0
- See Also:
-
async
Queues the givenConsumerwith the given arguments to be run asychronously, as soon as possible.See
async(Runnable)for usage hints regarding theasyncmethods.- Parameters:
handler- The handlerargs- Arguments to be passed to the handler- Since:
- 2.11.0
- See Also:
-
exit
public static void exit()SeeTaskScheduler.exit(). Called withI. -
setErrorHandler
SeeTaskScheduler.setErrorHandler(Consumer). Called withI.- Parameters:
errorHandler- The error handler- Since:
- 2.6
-
I