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 TaskScheduler
TheTaskScheduler
instance.static final TaskScheduler
TheTaskScheduler
instance, an alias ofI
. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Queues the givenRunnable
to be run asychronously, as soon as possible.static void
Queues the givenConsumer
with the given arguments to be run asychronously, as soon as possible.static boolean
clear
(long id) Deprecated.static boolean
Deprecated.Since 2.9.1, useI
static void
exit()
SeeTaskScheduler.exit()
.static TaskScheduler.TimerTask
Deprecated.Since 2.9.1, useI
static TaskScheduler.TimerTask
Deprecated.Since 2.9.1, useI
static void
setErrorHandler
(Consumer<Throwable> errorHandler) static TaskScheduler.TimerTask
Deprecated.Since 2.9.1, useI
static TaskScheduler.TimerTask
Deprecated.Since 2.9.1, useI
-
Field Details
-
I
TheTaskScheduler
instance.- Since:
- 2.9.1
- See Also:
-
TASKS
TheTaskScheduler
instance, an alias ofI
.This constant may be used instead of
I
in 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.TimerTask
instance - 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.TimerTask
instance - Since:
- 2.1
-
interval
Deprecated.Since 2.9.1, useI
- Parameters:
handler
- The handlertimeout
- The interval in milliseconds- Returns:
- The
TaskScheduler.TimerTask
instance - 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.TimerTask
instance - Since:
- 2.1
-
clear
Deprecated.Since 2.9.1, useI
- Parameters:
tt
- TheTaskScheduler.TimerTask
to cancel- Returns:
true
if tt is notnull
- Since:
- 2.1
-
clear
Deprecated.Since 2.9.1, useI
- Parameters:
id
- The id of theTaskScheduler.TimerTask
to cancel- Returns:
true
if the task was found and successfully canceled- Since:
- 2.1
-
async
Queues the givenRunnable
to 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 dedicatedTaskQueueExecutor
should be used instead.- Parameters:
handler
- The handler- Since:
- 2.11.0
- See Also:
-
async
Queues the givenConsumer
with the given arguments to be run asychronously, as soon as possible.See
async(Runnable)
for usage hints regarding theasync
methods.- 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