本文整理汇总了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);
}
});
}
}
示例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);
}
});
}
}
示例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);
}
});
}
}
示例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();
}
}
});
}
示例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);
}
}
示例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));
}
}
示例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);
}