Klasse BoundedAsyncOperationQueue

java.lang.Object
de.delinkedde.areashopreborn.application.BoundedAsyncOperationQueue
Alle implementierten Schnittstellen:
AutoCloseable

public final class BoundedAsyncOperationQueue extends Object implements AutoCloseable
Serializes asynchronous operations without owning or blocking a thread.

The bounded queue protects the server from multiplying per-tick work when many users start expensive workflows simultaneously. Priority submissions are intended for compensation and recovery work and are placed before ordinary waiting jobs.

  • Konstruktordetails

    • BoundedAsyncOperationQueue

      public BoundedAsyncOperationQueue(int maximumQueued)
      Creates a serial asynchronous operation queue.
      Parameter:
      maximumQueued - maximum waiting jobs in addition to the active job
  • Methodendetails

    • submit

      public <T> CompletableFuture<T> submit(Supplier<CompletableFuture<T>> operation)
      Submits ordinary work behind already waiting jobs.
      Typparameter:
      T - result type
      Parameter:
      operation - lazy asynchronous operation
      Gibt zurück:
      future completed with the operation result
    • submitPriority

      public <T> CompletableFuture<T> submitPriority(Supplier<CompletableFuture<T>> operation)
      Submits recovery work before ordinary waiting jobs.
      Typparameter:
      T - result type
      Parameter:
      operation - lazy asynchronous recovery operation
      Gibt zurück:
      future completed with the operation result
    • close

      public void close()
      Rejects new and waiting jobs while allowing the already active stage to finish.
      Angegeben von:
      close in Schnittstelle AutoCloseable