Class GatewayTask<T>
java.lang.Object
net.dv8tion.jda.internal.utils.concurrent.task.GatewayTask<T>
- All Implemented Interfaces:
Task<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels the task and will emit aCancellationException
.get()
Blocks the current thread until the result is ready.boolean
Whether this task has started.Provide a callback for exception handling.onSetTimeout
(LongConsumer setTimeout) Provide a callback for success handling.setTimeout
(Duration timeout) Change the timeout duration for this task.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.utils.concurrent.Task
setTimeout
-
Constructor Details
-
GatewayTask
-
-
Method Details
-
onSetTimeout
-
isStarted
public boolean isStarted()Description copied from interface:Task
Whether this task has started. -
onError
Description copied from interface:Task
Provide a callback for exception handling.
This is an asynchronous operation.The error will be logged regardless of your callback, this only exists to handle failures for other purposes.
-
onSuccess
Description copied from interface:Task
Provide a callback for success handling.
This is an asynchronous operation. -
setTimeout
Description copied from interface:Task
Change the timeout duration for this task.
This may be ignored for certain operations.The provided timeout is relative to the start time of the task. If the time has already passed, this will immediately cancel the task.
- Specified by:
setTimeout
in interfaceTask<T>
- Parameters:
timeout
- The new timeout duration- Returns:
- The current Task instance for chaining
-
get
Description copied from interface:Task
Blocks the current thread until the result is ready.
This will not work on the default JDA event thread because it might depend on other events to be processed, which could lead to a deadlock. -
cancel
public void cancel()Description copied from interface:Task
Cancels the task and will emit aCancellationException
.
-