Package edu.wpi.grip.core.util
Class SafeShutdown
- java.lang.Object
-
- edu.wpi.grip.core.util.SafeShutdown
-
public final class SafeShutdown extends java.lang.Object
This class should be used to shutdown GRIP safely. This is because shutdown hooks may throw exceptions, as such we need to know if the application being is shutdown.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SafeShutdown.ExitCode
Exit codes used by the GRIP application.static interface
SafeShutdown.PreSystemExitHook
-
Field Summary
Fields Modifier and Type Field Description static boolean
stopping
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
exit(SafeShutdown.ExitCode statusCode)
Helper method that passes null as the PreSystemExitHook.static void
exit(SafeShutdown.ExitCode statusCode, SafeShutdown.PreSystemExitHook hook)
Shutdown's the VM in such a way that flags that the vm is stopping.static void
flagStopping()
Flags that the application is shutting down.static boolean
isStopping()
HACK! Shutdown hooks can throw exceptions.
-
-
-
Method Detail
-
exit
public static void exit(SafeShutdown.ExitCode statusCode, @Nullable SafeShutdown.PreSystemExitHook hook)
Shutdown's the VM in such a way that flags that the vm is stopping. This is so that we don't run the normal exception handling code when shutting down the application.- Parameters:
statusCode
- exit status.hook
- The hook to run before the System shutdown. This will be run after stopping has been flagged true. This is nullable.- See Also:
System.exit(int)
-
exit
public static void exit(SafeShutdown.ExitCode statusCode)
Helper method that passes null as the PreSystemExitHook.- Parameters:
statusCode
- exit status.- See Also:
exit(ExitCode, PreSystemExitHook)
-
isStopping
public static boolean isStopping()
HACK! Shutdown hooks can throw exceptions. On Windows, the static method afterLoader.loadLibrary(java.net.URL[], java.lang.String, java.lang.String...)
throws such an exception in a shutdown hook.- Returns:
- True if if the application is shutting down.
- See Also:
- GRIP Issue, Bytedeco issue
-
flagStopping
public static void flagStopping()
Flags that the application is shutting down.
-
-