ProcessFinalization

sealed external interface ProcessFinalization(source)

Functions

Link copied to clipboard
abstract fun <T : Any> register(ref: T, callback: (ref: T, event: String) -> Unit)

This function registers a callback to be called when the process emits the exit event if the ref object was not garbage collected. If the object ref was garbage collected before the exit event is emitted, the callback will be removed from the finalization registry, and it will not be called on process exit.

Link copied to clipboard
abstract fun <T : Any> registerBeforeExit(ref: T, callback: (ref: T, event: String) -> Unit)

This function behaves exactly like the register, except that the callback will be called when the process emits the beforeExit event if ref object was not garbage collected.

Link copied to clipboard
abstract fun unregister(ref: Any)

This function remove the register of the object from the finalization registry, so the callback will not be called anymore.