Class GatewayTask<T>

java.lang.Object
net.dv8tion.jda.internal.utils.concurrent.task.GatewayTask<T>
All Implemented Interfaces:
Task<T>

public class GatewayTask<T> extends Object implements Task<T>
  • Constructor Details

  • Method Details

    • onSetTimeout

      public GatewayTask<T> onSetTimeout(LongConsumer setTimeout)
    • isStarted

      public boolean isStarted()
      Description copied from interface: Task
      Whether this task has started.
      Specified by:
      isStarted in interface Task<T>
      Returns:
      True, if this task has already started.
    • onError

      @Nonnull public Task<T> onError(@Nonnull Consumer<? super Throwable> callback)
      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.

      Specified by:
      onError in interface Task<T>
      Parameters:
      callback - The error callback
      Returns:
      The current Task instance for chaining
    • onSuccess

      @Nonnull public Task<T> onSuccess(@Nonnull Consumer<? super T> callback)
      Description copied from interface: Task
      Provide a callback for success handling.
      This is an asynchronous operation.
      Specified by:
      onSuccess in interface Task<T>
      Parameters:
      callback - The success callback
      Returns:
      The current Task instance for chaining
    • setTimeout

      @Nonnull public Task<T> setTimeout(@Nonnull Duration timeout)
      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 interface Task<T>
      Parameters:
      timeout - The new timeout duration
      Returns:
      The current Task instance for chaining
    • get

      @Nonnull public T 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.
      Specified by:
      get in interface Task<T>
      Returns:
      The result value
    • cancel

      public void cancel()
      Description copied from interface: Task
      Cancels the task and will emit a CancellationException.
      Specified by:
      cancel in interface Task<T>