All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.com.github.lolgab.scalanativecrypto.internal.CtxFinalizer.scala Maven / Gradle / Ivy

The newest version!
package java.com.github.lolgab.scalanativecrypto.internal

import java.lang.ref.WeakReference
import java.lang.ref.WeakReferenceRegistry

final class CtxFinalizer[T](
    weakRef: WeakReference[_],
    private var ctx: T,
    finalizationFunction: T => Unit
) {
  WeakReferenceRegistry.addHandler(weakRef, apply)

  def apply(): Unit = {
    if (ctx != null) {
      finalizationFunction(ctx)
      ctx = null.asInstanceOf[T]
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy