Class SerialRequestWorker

java.lang.Object
com.ultikits.ultitools.utils.SerialRequestWorker

final class SerialRequestWorker extends Object
One dedicated worker thread per connection for file, server.properties and pending module change requests (upm.pending.list and upm.pending.revoke). These handlers can block on disk I/O, so running them on the connection's own thread would delay heartbeats, acknowledgements and other requests.

Order. One thread and a FIFO queue: the wrapped requests are handled one at a time, in arrival order, so a files.write followed by a files.read of the same path still reads what was written.

Bounds. At most capacity requests wait; one more is answered at once with the generic error rate_limited (contract section 6) and never runs. The thread is a daemon named "UltiTools-CloudFiles" and ends when idle.

Failures. The router no longer surrounds a handler that runs here, so this worker answers as the router would: an InvalidFrameException becomes invalid_message (its code), any other runtime failure internal_error without the exception text. The reply goes out through the connection's channel.

Close. close() drops the requests that had not started (their connection is gone, so a reply could not reach the gateway, and an unanswered request is one the gateway reports as timed out -- never run twice) and lets the running one finish. Never waits for the thread.

Shutdown. A request the ShutdownGate covers (files.write, files.delete, properties.update) asks the gate again when it starts here, because it may have been queued before UltiTools#onDisable began: refused, it is answered with its shutting-down failure and never runs; let in, it keeps the gate's permit until it is answered, so onDisable waits for it before the action log closes. upm.pending.revoke takes its permit inside PendingChangesHandler; upm.pending.list is read-only and does not take one.

  • Field Details

  • Constructor Details

    • SerialRequestWorker

      SerialRequestWorker(int capacity)
      A worker whose requests are never refused for a shutdown.
      Parameters:
      capacity - how many requests may wait behind the running one; at least 1
    • SerialRequestWorker

      SerialRequestWorker(int capacity, ShutdownGate shutdown)
      Parameters:
      capacity - how many requests may wait behind the running one; at least 1
      shutdown - the shutdown gate a covered request asks when it starts
  • Method Details