Package java.lang.ref

Examples of java.lang.ref.Reference


         * Start execution.
         */
        public void run() {
            while (true) {
                try {
                    Reference ref = REFERENCE_QUEUE.remove();
                    if (ref != null) {
                        handleReference(ref);
                    }
                } catch (InterruptedException e) {
                    LOG.debug("ReferenceQueueThread interrupted", e);
View Full Code Here


    /** Close the native library we're mapped to. */
    public void dispose() {
        synchronized(libraries) {
            for (Iterator i=libraries.values().iterator();i.hasNext();) {
                Reference ref = (WeakReference)i.next();
                if (ref.get() == this) {
                    i.remove();
                }
            }
        }
        synchronized(this) {
View Full Code Here

        if (!type.isInterface())
            throw new IllegalArgumentException("Callback type must be an interface");
        Map map = direct ? directCallbackMap : callbackMap;
        synchronized(callbackMap) {
            Callback cb = null;
            Reference ref = (Reference)pointerCallbackMap.get(p);
            if (ref != null) {
                cb = (Callback)ref.get();
                if (cb != null && !type.isAssignableFrom(cb.getClass())) {
                    throw new IllegalStateException("Pointer " + p + " already mapped to " + cb);
                }
                return cb;
            }
View Full Code Here

     * @param md The method descriptor
     * @return The cached method
     */
  private static Method getCachedMethod(MethodDescriptor md) {
        if (CACHE_METHODS) {
            Reference methodRef = (Reference)cache.get(md);
            if (methodRef != null) {
                return (Method)methodRef.get();
            }
        }
        return null;
    }
View Full Code Here

    private final Class nativeType;
    private final NativeMapped instance;

    public static NativeMappedConverter getInstance(Class cls) {
        synchronized(converters) {
            Reference r = (Reference)converters.get(cls);
            NativeMappedConverter nmc = r != null ? (NativeMappedConverter)r.get() : null;
            if (nmc == null) {
                nmc = new NativeMappedConverter(cls);
                converters.put(cls, new SoftReference(nmc));
            }
            return nmc;
View Full Code Here

        if (!type.isInterface())
            throw new IllegalArgumentException("Callback type must be an interface");
        Map map = direct ? directCallbackMap : callbackMap;
        synchronized(callbackMap) {
            Callback cb = null;
            Reference ref = (Reference)pointerCallbackMap.get(p);
            if (ref != null) {
                cb = (Callback)ref.get();
                if (cb != null && !type.isAssignableFrom(cb.getClass())) {
                    throw new IllegalStateException("Pointer " + p + " already mapped to " + cb);
                }
                return cb;
            }
View Full Code Here

        Set values;
        synchronized(libraries) {
            values = new HashSet(libraries.values());
        }
        for (Iterator i=values.iterator();i.hasNext();) {
            Reference ref = (WeakReference)i.next();
            NativeLibrary lib = (NativeLibrary)ref.get();
            if (lib != null) {
                lib.dispose();
            }
        }
    }
View Full Code Here

        public void run() {

            while(true) {

                try {
                    Reference ref = referenceQueue.remove();

                    if ( ref != null ) {
                        HostConfiguration config = (HostConfiguration)
                            referenceToHostConfig.get(ref);
                        referenceToHostConfig.remove(ref);
View Full Code Here

     * care must be taken if, for instance, you want stale
     * mappings to be removed on a periodic basis by some
     * background thread.
     */
    protected void purge() {
        Reference ref = queue.poll();
        while (ref != null) {
            purge(ref);
            ref = queue.poll();
        }
    }
View Full Code Here

     * care must be taken if, for instance, you want stale
     * mappings to be removed on a periodic basis by some
     * background thread.
     */
    private void purge() {
        Reference ref = queue.poll();
        while (ref != null) {
            purge(ref);
            ref = queue.poll();
        }
    }
View Full Code Here

TOP

Related Classes of java.lang.ref.Reference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.