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

jjbridge.engine.utils.NativeReference Maven / Gradle / Ivy

There is a newer version: 0.4.0
Show newest version
package jjbridge.engine.utils;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

/**
 * This class associates a {@link CleanUpAction} to a {@link PhantomReference}.
 * 

This allows to perform additional clean up operation before the reference is cleared by the garbage collector.

* * @see ReferenceMonitor * */ public class NativeReference extends PhantomReference { private final CleanUpAction cleanUpAction; public final long id; NativeReference(long id, T referent, ReferenceQueue q, CleanUpAction cleanUpAction) { super(referent, q); this.id = id; this.cleanUpAction = cleanUpAction; } /** * Performs the {@link CleanUpAction} passed in * {@link #NativeReference(long, Object, ReferenceQueue, CleanUpAction)}. * */ public void cleanUp() { this.cleanUpAction.cleanUp(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy