A graceful-shutdown coordinator for a zRPC server (← go-zero'sproc.AddShutdownListener + gRPC's GracefulStop): once shutdown isinitiated the server stops admitting new calls, but calls already in flight areallowed to run to completion. A call brackets its work between begin_call andend_call; begin_call returns false when the server is shutting down, whichthe transport surfaces as Unavailable — exactly the status a client sees oncea server has stopped listening. The server is fully drained once shutdown hasbeen initiated and no calls remain in flight.
The counter is plain mutable state, which is safe under moonbitlang/async'scooperative single-threaded scheduling: begin_call/end_call never yield, sothe count is only observed at await points between them.
Admit a new call: register it as in-flight and return true, unless shutdownhas been initiated, in which case the call is refused (false) and the count isleft untouched.
Mark an admitted call finished, dropping it from the in-flight count. Only callit for a call that begin_call admitted; the count never goes below zero.
Whether the server is fully drained: shutdown initiated and no call in flight.A supervisor loops on this (yielding between checks) to know the last in-flightRPC has finished and the process may exit.