Package io.deephaven.base.system
Class AsyncSystem
java.lang.Object
io.deephaven.base.system.AsyncSystem
A set of conventions for logging exceptions and asynchronously exiting the JVM.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
exit
(String name, int status, PrintStream out) Starts an asynchronous call toSystem.exit(int)
.static void
exitCaught
(Thread thread, Throwable throwable, int status, PrintStream out) Equivalent toexitCaught(thread, throwable, status, out, null)
.static void
exitCaught
(Thread thread, Throwable throwable, int status, PrintStream out, @Nullable String message) Prints out a message and stacktrace, and then callsexit(String, int, PrintStream)
.static void
exitUncaught
(Thread thread, Throwable throwable, int status, PrintStream out) Prints out a message and stacktrace, and then callsexit(String, int, PrintStream)
.uncaughtExceptionHandler
(int status, PrintStream out) Creates anThread.UncaughtExceptionHandler
which calls out toexitUncaught(Thread, Throwable, int, PrintStream)
.
-
Constructor Details
-
AsyncSystem
public AsyncSystem()
-
-
Method Details
-
uncaughtExceptionHandler
Creates anThread.UncaughtExceptionHandler
which calls out toexitUncaught(Thread, Throwable, int, PrintStream)
.- Parameters:
status
- the exit status- Returns:
- the uncaught exception handler
-
exit
Starts an asynchronous call toSystem.exit(int)
. A new daemon thread will be started and it will invoke onlySystem.exit(status)
. In the event thatSystem.exit(int)
throws an exception, the name of the thread and the stacktrace will be printed out.Note: this call will return, unlike a direct call to
System.exit(int)
. Callers should manage this as appropriate.- Parameters:
name
- the name to attach to the threadstatus
- exit statusout
- the output print stream (on exception)
-
exitUncaught
Prints out a message and stacktrace, and then callsexit(String, int, PrintStream)
. This should only be called fromuncaught exception handlers
.- Parameters:
thread
- the threadthrowable
- the throwablestatus
- the statusout
- the print stream
-
exitCaught
Equivalent toexitCaught(thread, throwable, status, out, null)
. -
exitCaught
public static void exitCaught(Thread thread, Throwable throwable, int status, PrintStream out, @Nullable @Nullable String message) Prints out a message and stacktrace, and then callsexit(String, int, PrintStream)
. This can be called from a thread which catches its own exceptions and wants to exit.- Parameters:
thread
- the threadthrowable
- the throwablestatus
- the statusout
- the print streammessage
- the optional additional message
-