Skip to content

Commit

Permalink
Remove deprecated/no-op freezing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rickclephas committed Oct 21, 2024
1 parent 238e8f3 commit 7647936
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.rickclephas.kmp.nsexceptionkt.core

import kotlin.experimental.ExperimentalNativeApi
import kotlin.concurrent.AtomicReference
import kotlin.native.concurrent.freeze

/**
* Wraps the unhandled exception hook such that the provided [hook] is invoked
Expand All @@ -12,13 +11,13 @@ import kotlin.native.concurrent.freeze
* @see terminateWithUnhandledException
*/
@InternalNSExceptionKtApi
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
@OptIn(ExperimentalNativeApi::class)
public fun wrapUnhandledExceptionHook(hook: (Throwable) -> Unit) {
val prevHook = AtomicReference<ReportUnhandledExceptionHook?>(null)
val wrappedHook: ReportUnhandledExceptionHook = {
hook(it)
prevHook.value?.invoke(it)
terminateWithUnhandledException(it)
}
prevHook.value = setUnhandledExceptionHook(wrappedHook.freeze())
prevHook.value = setUnhandledExceptionHook(wrappedHook)
}

0 comments on commit 7647936

Please sign in to comment.