Package com.swoval.runtime
Class ShutdownHooks
- java.lang.Object
-
- com.swoval.runtime.ShutdownHooks
-
public class ShutdownHooks extends java.lang.Object
Provides an api for adding shutdown hooks. This exists because there is noRuntime.addShutdownHook(java.lang.Thread)
implementation available on scala.js. The hooks may be added with a priority that controls the order in which the hooks run. Lower values run first.
-
-
Constructor Summary
Constructors Constructor Description ShutdownHooks()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
addHook(int priority, java.lang.Runnable runnable)
Add a removable hook to run at shutdown.static void
removeHook(int id)
Remove a shutdown hook that was added viaaddHook(int, Runnable)
.
-
-
-
Method Detail
-
addHook
public static int addHook(int priority, java.lang.Runnable runnable)
Add a removable hook to run at shutdown.- Parameters:
priority
- controls the ordering of this hook. Lower values run first.runnable
- the shutdown task to run- Returns:
- an id that can be used to later remove the runnable if it is no longer needed.
-
removeHook
public static void removeHook(int id)
Remove a shutdown hook that was added viaaddHook(int, Runnable)
.- Parameters:
id
- the id returned byaddHook(int, Runnable)
-
-