本文整理汇总了Java中org.openide.util.Mutex.ExceptionAction方法的典型用法代码示例。如果您正苦于以下问题:Java Mutex.ExceptionAction方法的具体用法?Java Mutex.ExceptionAction怎么用?Java Mutex.ExceptionAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.util.Mutex
的用法示例。
在下文中一共展示了Mutex.ExceptionAction方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runProtected
import org.openide.util.Mutex; //导入方法依赖的package包/类
/**
* Runs given action both in Project read lock and synchronized on given cache
* @param protectedCache Synchronized cache list, e.g. sourceLists, binaryLists, etc.
* @param action Action to run
* @return created or cached module list
* @throws java.io.IOException
*/
private static ModuleList runProtected(final Object protectedCache, final Mutex.ExceptionAction<ModuleList> action) throws IOException {
try {
LOG.log(Level.FINER, "runProtected: sync 0");
return ProjectManager.mutex().readAccess(new Mutex.ExceptionAction<ModuleList>() {
public ModuleList run() throws Exception {
LOG.log(Level.FINER, "runProtected: sync 1");
synchronized (protectedCache) {
return action.run();
}
}
});
} catch (MutexException e){
throw (IOException) e.getException();
}
}
示例2: DeferredTask
import org.openide.util.Mutex; //导入方法依赖的package包/类
public DeferredTask (
@NonNull final Collection<Source> sources,
@NonNull final Mutex.ExceptionAction<Void> task,
@NonNull final ScanSync sync,
@NonNull final Lookup context) {
assert sources != null;
assert task != null;
assert sync != null;
assert context != null;
this.sources = sources;
this.task = task;
this.sync = sync;
this.context = context;
}
示例3: writeAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException {
return doEventAccess(action);
}
示例4: readAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException {
return doEventAccess(action);
}
示例5: runWhenScanFinished
import org.openide.util.Mutex; //导入方法依赖的package包/类
@NonNull
public static Future<Void> runWhenScanFinished (
@NonNull final Mutex.ExceptionAction<Void> task,
@NonNull final Collection<Source> sources) throws ParseException {
assert task != null;
assert sources != null;
final ScanSync sync = new ScanSync (task);
final DeferredTask r = new DeferredTask (sources, task, sync, Lookup.getDefault());
//0) Add speculatively task to be performed at the end of background scan
todo.add (r);
boolean indexing = TaskProcessor.getIndexerBridge().isIndexing();
if (indexing) {
return sync;
}
//1) Try to aquire javac lock, if successfull no task is running
// perform the given taks synchronously if it wasn't already performed
// by background scan.
final boolean locked = lock.readLock().tryLock();
if (locked) {
try {
LOG.log(
Level.FINE,
"runWhenScanFinished:entry", //NOI18N
task);
if (todo.remove(r)) {
try {
TaskProcessor.runUserTask(task, sources);
} finally {
sync.taskFinished();
}
}
LOG.log(
Level.FINE,
"runWhenScanFinished:exit", //NOI18N
task);
} finally {
lock.readLock().unlock();
}
}
return sync;
}
示例6: ScanSync
import org.openide.util.Mutex; //导入方法依赖的package包/类
public ScanSync (final Mutex.ExceptionAction<Void> task) {
assert task != null;
this.task = task;
this.sync = new CountDownLatch (1);
this.canceled = new AtomicBoolean (false);
}
示例7: writeAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException {
return getDelegate().writeAccess(action);
}
示例8: readAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException {
return getDelegate().readAccess(action);
}
示例9: writeAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException {
return handle();
}
示例10: readAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException {
return handle();
}
示例11: writeAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
<T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException;
示例12: readAccess
import org.openide.util.Mutex; //导入方法依赖的package包/类
<T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException;