当前位置: 首页>>代码示例>>Java>>正文


Java Unreferenced类代码示例

本文整理汇总了Java中java.rmi.server.Unreferenced的典型用法代码示例。如果您正苦于以下问题:Java Unreferenced类的具体用法?Java Unreferenced怎么用?Java Unreferenced使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Unreferenced类属于java.rmi.server包,在下文中一共展示了Unreferenced类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refSetRemove

import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
 * Remove endpoint from the reference set.
 */
synchronized private void refSetRemove(VMID vmid) {
    // remove notification request
    DGCImpl.getDGCImpl().unregisterTarget(vmid, this);

    if (refSet.removeElement(vmid) && refSet.isEmpty()) {
        // reference set is empty, so server can be garbage collected.
        // remove object from table.
        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE,
                "reference set is empty: target = " + this);
        }

        /*
         * If the remote object implements the Unreferenced interface,
         * invoke its unreferenced callback in a separate thread.
         */
        Remote obj = getImpl();
        if (obj instanceof Unreferenced) {
            final Unreferenced unrefObj = (Unreferenced) obj;
            AccessController.doPrivileged(
                new NewThreadAction(() -> {
                    Thread.currentThread().setContextClassLoader(ccl);
                    AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
                        unrefObj.unreferenced();
                        return null;
                    }, acc);
                }, "Unreferenced-" + nextThreadNum++, false, true)).start();
                // REMIND: access to nextThreadNum not synchronized; you care?
        }

        unpinImpl();
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:37,代码来源:Target.java

示例2: unreferenced

import java.rmi.server.Unreferenced; //导入依赖的package包/类
private synchronized void unreferenced() {
    final Object obj = ref.get();

    if (obj instanceof Unreferenced) {
        /*
         * Spawn unreferenced thread.
         * Start this thread with setDaemon(false) to protect VM
         * from exiting while unreferencing the object.
         * The thread is started in non-system group
         * (see comment for CreateThreadAction class).
         */
        Thread uThread = ((Thread) AccessController.doPrivileged(
                new CreateThreadAction(new Runnable() {
                    public void run() {
                        AccessController.doPrivileged(
                                new PrivilegedAction() {
                                    public Object run() {
                                        ((Unreferenced) obj).unreferenced();
                                        return null;
                                    }
                                }, acc);
                    }
                }, "Unreferenced", false, false))); //$NON-NLS-1$
        uThread.setContextClassLoader(loader);
        uThread.start();
    }
    ref.makeStrong(false);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:RMIObjectInfo.java

示例3: clean

import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
 * A per {@link java.rmi.dgc.DGC#clean(ObjID[], long, VMID, boolean)}
 * implementation of the dirty method
 * 
 * @param vmid
 *            The {@link java.rmi.dgc.VMID} updated.
 * @see java.rmi.dgc.DGC
 */
public final void clean(VMID vmid) {

    if (vmIdExpirationTimeMap.containsKey(vmid)) {
        vmIdExpirationTimeMap.remove(vmid);
        dgcCount--;
        if (vmIdExpirationTimeMap.isEmpty()) {
            if (StrongRef instanceof Unreferenced) {
                ((Unreferenced) StrongRef).unreferenced();
            }
            StrongRef = null;
        }
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:22,代码来源:DGCData.java

示例4: removeOlderThan

import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
 * Eliminates the VMID's which's lease times had expired.
 * 
 * @param time
 *            The time to be taken as bound.
 * @return the eliminated VMIDs.
 */
public final Set<VMID> removeOlderThan(long time) {
    /*
     * The return value is not necesary, is there just for possible
     * extensions.
     */

    HashSet<VMID> retVMIDs = new HashSet<VMID>();
    synchronized (vmIdExpirationTimeMap) {
        Iterator<VMID> iter = vmIdExpirationTimeMap.keySet().iterator();

        while (iter.hasNext()) {
            VMID currentVMID = iter.next();
            Long iterTime = vmIdExpirationTimeMap.get(currentVMID);
            
            if (iterTime < time) {
                iter.remove();
                dgcCount--;
                if (vmIdExpirationTimeMap.isEmpty()) {
                    if (StrongRef instanceof Unreferenced) {
                        ((Unreferenced) StrongRef).unreferenced();
                    }
                    StrongRef = null;
                }
                retVMIDs.add(currentVMID);
            }
        }
    }

    return retVMIDs;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:38,代码来源:DGCData.java

示例5: removeOlderThan

import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
 * Eliminates the VMID's which's lease times had expired.
 * 
 * @param time
 *            The time to be taken as bound.
 * @return the eliminated VMIDs.
 */
public final Set<VMID> removeOlderThan(long time) {
    /*
     * The return value is not necesary, is there just for possible
     * extensions.
     */

    HashSet<VMID> retVMIDs = new HashSet<VMID>();
    synchronized (vmIdExpirationTimeMap) {
        Iterator<VMID> iter = vmIdExpirationTimeMap.keySet().iterator();

        while (iter.hasNext()) {
            VMID currentVMID = iter.next();
            Long iterTime = vmIdExpirationTimeMap.get(currentVMID);
            if (iterTime < time) {
                iter.remove();
                dgcCount--;
                if (vmIdExpirationTimeMap.isEmpty()) {
                    if (StrongRef instanceof Unreferenced) {
                        ((Unreferenced) StrongRef).unreferenced();
                    }
                    StrongRef = null;
                }
                retVMIDs.add(currentVMID);
            }
        }
    }

    return retVMIDs;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:37,代码来源:DGCData.java

示例6: refSetRemove

import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
 * Remove endpoint from the reference set.
 */
synchronized private void refSetRemove(VMID vmid) {
    // remove notification request
    DGCImpl.getDGCImpl().unregisterTarget(vmid, this);

    if (refSet.removeElement(vmid) && refSet.isEmpty()) {
        // reference set is empty, so server can be garbage collected.
        // remove object from table.
        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE,
                "reference set is empty: target = " + this);
        }

        /*
         * If the remote object implements the Unreferenced interface,
         * invoke its unreferenced callback in a separate thread.
         */
        Remote obj = getImpl();
        if (obj instanceof Unreferenced) {
            final Unreferenced unrefObj = (Unreferenced) obj;
            final Thread t =
                java.security.AccessController.doPrivileged(
                    new NewThreadAction(new Runnable() {
                        public void run() {
                            unrefObj.unreferenced();
                        }
                    }, "Unreferenced-" + nextThreadNum++, false, true));
            // REMIND: access to nextThreadNum not synchronized; you care?
            /*
             * We must manually set the context class loader appropriately
             * for threads that may invoke user code (see bugid 4171278).
             */
            java.security.AccessController.doPrivileged(
                new java.security.PrivilegedAction<Void>() {
                    public Void run() {
                    t.setContextClassLoader(ccl);
                    return null;
                }
            });

            t.start();
        }

        unpinImpl();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:Target.java


注:本文中的java.rmi.server.Unreferenced类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。