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

neureka.devices.opencl.utility.WeakTensorReference Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package neureka.devices.opencl.utility;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

public class WeakTensorReference extends WeakReference
{
    /**
     * Creates a new phantom reference that refers to the given object and
     * is registered with the given queue.
     *
     * 

It is possible to create a phantom reference with a {@code null} * queue, but such a reference is completely useless: Its {@code get} * method will always return {@code null} and, since it does not have a queue, * it will never be enqueued. * * @param referent the object the new phantom reference will refer to * @param q the queue with which the reference is to be registered, * or {@code null} if registration is not required */ private final int _hash; public WeakTensorReference( T referent, ReferenceQueue q ) { super(referent, q); _hash = referent.hashCode(); } @Override public int hashCode() { return _hash; } @Override public boolean equals( Object o ) { if ( !(o instanceof WeakTensorReference) ) return false; if ( o.hashCode() == _hash ) return true; else { T value = get(); return value != null && o == value; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy