Class ServerLifecycle

java.lang.Object
dev.relism.flash.transport.ServerLifecycle
All Implemented Interfaces:
ServerHandle

public final class ServerLifecycle extends Object implements ServerHandle
Owns the server's lifecycle: the accept threads (one per listener × TransportTuning.ACCEPT_THREADS), the active-socket registry, and the two-stage shutdownDrainTimeoutMs (during which Http1Connection forces Connection: close on the next response once it observes isStopped()), then force-close whatever remains.

Implements ServerHandle directly — its three methods already match that contract exactly, so no separate wrapper class is needed.

  • Constructor Details

  • Method Details

    • isStopped

      public boolean isStopped()
      Whether the server has begun shutting down. Passed down to every connection as a BooleanSupplier so in-flight request loops can drain promptly instead of waiting for their next keep-alive request.
    • start

      public void start()
      Description copied from interface: ServerHandle
      Starts the accept loop on a background platform thread. Returns immediately.
      Specified by:
      start in interface ServerHandle
    • startAndBlock

      public void startAndBlock()
      Description copied from interface: ServerHandle
      Starts the accept loop and blocks the calling thread until the server is stopped. Suitable for use in main() when no other work is needed after startup.
      Specified by:
      startAndBlock in interface ServerHandle
    • stop

      public CompletableFuture<Void> stop()
      Description copied from interface: ServerHandle
      Gracefully stops the server, draining active connections.
      Specified by:
      stop in interface ServerHandle