Class ServerRuntime

java.lang.Object
zeroecho.pki.server.http.ServerRuntime
All Implemented Interfaces:
AutoCloseable

public final class ServerRuntime extends Object implements AutoCloseable
Centralized owner of all bounded server-created threads, queues and permits.
  • Method Details

    • tryAdmit

      public boolean tryAdmit()
      Tries to reserve one request-admission permit without waiting. A successful caller must invoke releaseAdmission() exactly once. Shutdown may start after this check, so later submission can still fail.
      Returns:
      whether a permit was acquired while acceptance was observed enabled
    • releaseAdmission

      public void releaseAdmission()
      Returns a permit previously acquired by tryAdmit(). Calling without a matching acquisition increases capacity incorrectly; the caller must enforce pairing even when request processing fails.
    • execute

      Executes one operation through the owned bounded queue and waits for its result. The caller owns admission pairing. A timeout or interruption requests cooperative cancellation and interrupts the worker; execution tracking remains until the worker actually exits. Already committed side effects are not rolled back.

      The operation must release its resources itself and must not transfer a live resource through the return value: a result produced after cancellation can be discarded. The caller must restore or propagate interruption.

      Type Parameters:
      T - independently owned, resource-free result type
      Parameters:
      deadline - positive wait bound no greater than the configured maximum
      operation - operation receiving the lifecycle-owned cancellation signal
      Returns:
      completed operation result
      Throws:
      IllegalArgumentException - if the deadline is outside the configured bound
      RejectedExecutionException - if the runtime is closing or its queue is full
      TimeoutException - if the deadline expires
      InterruptedException - if the waiting caller is interrupted
      ExecutionException - if operation execution fails
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable