ManualMemoryPressureObserver

A MemoryPressureObserver whose signals are pushed with emit.

Used as the base of platform observers, on platforms without an OS signal (JVM desktop), and as a deterministic fake in tests. Thread-safe: listeners may be added, removed, and notified concurrently.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The most recently reported level, or MemoryPressureLevel.NORMAL if none has been reported.

Functions

Link copied to clipboard
open override fun addListener(listener: MemoryPressureListener): AutoCloseable

Registers listener. Closing the returned handle unregisters it; closing it more than once is a no-op.

Link copied to clipboard
fun emit(newLevel: MemoryPressureLevel)

Records newLevel as currentLevel and notifies every registered listener in registration order.