phasync
Cancellation and cleanup / ShutdownException

Exception

ShutdownException

Thrown into the coroutines of a run by phasync::shutdown(): the program is stopping. It is a CancelledException, so it behaves like one: the coroutine meets it at its wait, its finally blocks run, and cleanup that must wait belongs in phasync::finally(). Code that only needs to stop catches nothing, or CancelledException; code that must tell someone why catches this.

Class synopsis#

class ShutdownException extends CancelledException implements RethrowExceptionInterface, \Stringable, \Throwable {

}

See also#

  • phasync::shutdownStop the program's coroutines: every coroutine but the caller, whatever frame it is in, gets $exception (a ShutdownException, which is a CancelledException) at its wait, as phasync::cancel() does, and has up to $window seconds to clean up: finally blocks, and phasync::finally() callbacks, which may wait. Returns how many are still running after that, for the caller to decide (for example to exit, dropping them).