public class LowMemoryWatcher
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
LowMemoryWatcher.LowMemoryWatcherType |
Modifier and Type | Method and Description |
---|---|
static void |
onLowMemorySignalReceived(boolean afterGc) |
static LowMemoryWatcher |
register(java.lang.Runnable runnable) |
static void |
register(java.lang.Runnable runnable,
Disposable parentDisposable) |
static LowMemoryWatcher |
register(java.lang.Runnable runnable,
LowMemoryWatcher.LowMemoryWatcherType notificationType)
Registers a runnable to run on low memory events
|
static void |
register(java.lang.Runnable runnable,
LowMemoryWatcher.LowMemoryWatcherType notificationType,
Disposable parentDisposable)
Registers a runnable to run on low memory events.
|
static <T> T |
runWithNotificationsSuppressed(Computable<T> runnable) |
void |
stop() |
public static <T> T runWithNotificationsSuppressed(Computable<T> runnable)
public static void onLowMemorySignalReceived(boolean afterGc)
public static LowMemoryWatcher register(java.lang.Runnable runnable, LowMemoryWatcher.LowMemoryWatcherType notificationType)
runnable
- the action which executes on low-memory condition. Can be executed:
- in arbitrary thread
- in unpredictable time
- multiple copies in parallel so please make it reentrant.notificationType
- When ONLY_AFTER_GC, then the runnable will be invoked only if the low-memory condition still exists after GC.
When ALWAYS, then the runnable also will be invoked when the low-memory condition is detected before GC.public static LowMemoryWatcher register(java.lang.Runnable runnable)
public static void register(java.lang.Runnable runnable, LowMemoryWatcher.LowMemoryWatcherType notificationType, Disposable parentDisposable)
public static void register(java.lang.Runnable runnable, Disposable parentDisposable)
public void stop()