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


Java Mutex.Action方法代码示例

本文整理汇总了Java中org.openide.util.Mutex.Action方法的典型用法代码示例。如果您正苦于以下问题:Java Mutex.Action方法的具体用法?Java Mutex.Action怎么用?Java Mutex.Action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.util.Mutex的用法示例。


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

示例1: fireChange

import org.openide.util.Mutex; //导入方法依赖的package包/类
private void fireChange() {
    if (!cs.hasListeners()) {
        return;
    }
    final Mutex.Action<Void> action = new Mutex.Action<Void>() {
        public Void run() {
            cs.fireChange();
            return null;
        }
    };
    if (ProjectManager.mutex().isWriteAccess()) {
        // Run it right now. postReadRequest would be too late.
        ProjectManager.mutex().readAccess(action);
    } else if (ProjectManager.mutex().isReadAccess()) {
        // Run immediately also. No need to switch to read access.
        action.run();
    } else {
        // Not safe to acquire a new lock, so run later in read access.
        RP.post(new Runnable() {
            public void run() {
                ProjectManager.mutex().readAccess(action);
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProjectProperties.java

示例2: fireChange

import org.openide.util.Mutex; //导入方法依赖的package包/类
private void fireChange() {
    cachedTime = -1L; // force reload
    if (!cs.hasListeners()) {
        return;
    }
    final Mutex.Action<Void> action = new Mutex.Action<Void>() {
        public Void run() {
            cs.fireChange();
            return null;
        }
    };
    if (ProjectManager.mutex().isWriteAccess()) {
        // Run it right now. postReadRequest would be too late.
        ProjectManager.mutex().readAccess(action);
    } else if (ProjectManager.mutex().isReadAccess()) {
        // Run immediately also. No need to switch to read access.
        action.run();
    } else {
        // Not safe to acquire a new lock, so run later in read access.
        RP.post(new Runnable() {
            public void run() {
                ProjectManager.mutex().readAccess(action);
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PropertyUtils.java

示例3: propertyChange

import org.openide.util.Mutex; //导入方法依赖的package包/类
public @Override final void propertyChange(PropertyChangeEvent evt) {
    String p = evt.getPropertyName();
    if (p != null && !p.startsWith("nbjdk.") && !p.startsWith("platforms.") && // NOI18N
            !p.equals(ClassPath.PROP_ENTRIES) && !p.equals(JavaPlatformManager.PROP_INSTALLED_PLATFORMS)) {
        return;
    }
    if (!changeSupport.hasListeners()) {
        return;
    }
    final Mutex.Action<Void> action = new Mutex.Action<Void>() {
        public @Override Void run() {
            changeSupport.fireChange();
            return null;
        }
    };
    // See ProjectProperties.PP.fireChange for explanation of this threading stuff:
    if (ProjectManager.mutex().isWriteAccess()) {
        ProjectManager.mutex().readAccess(action);
    } else if (ProjectManager.mutex().isReadAccess()) {
        action.run();
    } else {
        RP.post(new Runnable() {
            public @Override void run() {
                ProjectManager.mutex().readAccess(action);
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:Evaluator.java

示例4: runGuarded

import org.openide.util.Mutex; //导入方法依赖的package包/类
private <T> T runGuarded(@NonNull final Mutex.Action<T> action) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<T>(){
        @Override
        public T run() {
            synchronized(cpLock) {
                return action.run();
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ClassPathProviderImpl.java

示例5: runWithOnSaveTasksDisabled

import org.openide.util.Mutex; //导入方法依赖的package包/类
public static <T> T runWithOnSaveTasksDisabled(Mutex.Action<T> run) {
    Boolean originalIgnore = ignoreOnSaveTasks.get();
    ignoreOnSaveTasks.set(true);
    try {
        return run.run();
    } finally {
        ignoreOnSaveTasks.set(originalIgnore);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:BeforeSaveTasks.java

示例6: fireExternalChange

import org.openide.util.Mutex; //导入方法依赖的package包/类
/**
 * Fire a change of external provenance to all listeners.
 * When run under read or write access to <code>ProjectManager.mutex()</code>
 * property change is fired synchronously, otherwise fire asynchronously
 * under acquired read lock.
 * @param path path to the changed file (XML or properties)
 */
void fireExternalChange(final String path) {
    final Mutex.Action<Void> action = new ActionImpl(this, path);
    if (ProjectManager.mutex().isWriteAccess() || ProjectLibraryProvider.FIRE_CHANGES_SYNCH) {
        // Run it right now. postReadRequest would be too late.
        ProjectManager.mutex().readAccess(action);
    } else if (ProjectManager.mutex().isReadAccess()) {
        // Run immediately also. No need to switch to read access.
        action.run();
    } else {
        // Not safe to acquire a new lock, so run later in read access.
        rp().post(new RunnableImpl(action));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AntProjectHelper.java

示例7: runWithOnSaveTasksDisabled

import org.openide.util.Mutex; //导入方法依赖的package包/类
/**Don't use unless you know what you are doing.
 * 
 * @since 3.34
 */
public static <T> T runWithOnSaveTasksDisabled(Mutex.Action<T> run) {
    return BeforeSaveTasks.runWithOnSaveTasksDisabled(run);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:Utilities.java


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