Class BufferedRequest<T>

java.lang.Object
me.lucko.luckperms.common.cache.BufferedRequest<T>
Type Parameters:
T - the return type
Direct Known Subclasses:
SyncTask.Buffer

public abstract class BufferedRequest<T> extends Object
Thread-safe request buffer. Waits for the buffer time to pass before performing the operation. If the request is called again in that time, the buffer time is reset.
  • Constructor Details

    • BufferedRequest

      public BufferedRequest(long bufferTime, TimeUnit unit, SchedulerAdapter schedulerAdapter)
      Creates a new buffer with the given timeout millis
      Parameters:
      bufferTime - the timeout
      unit - the unit of the timeout
  • Method Details

    • request

      public CompletableFuture<T> request()
      Makes a request to the buffer
      Returns:
      the future
    • isEnqueued

      public boolean isEnqueued()
      Gets if the request buffer has been enqueued
      Returns:
      if the buffer is enqueued
    • requestDirectly

      public T requestDirectly()
      Requests the value, bypassing the buffer
      Returns:
      the value
    • perform

      protected abstract T perform()
      Performs the buffered task
      Returns:
      the result