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


Java Mutex.ExceptionAction方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ModuleList.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:RunWhenScanFinishedSupport.java

示例3: writeAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException {
    return doEventAccess(action);         
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:NbMutexEventProvider.java

示例4: readAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException {
    return doEventAccess(action);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:NbMutexEventProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:RunWhenScanFinishedSupport.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:RunWhenScanFinishedSupport.java

示例7: writeAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException {
    return getDelegate().writeAccess(action);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:LazyMutexImplementation.java

示例8: readAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException {
    return getDelegate().readAccess(action);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:LazyMutexImplementation.java

示例9: writeAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException {
    return handle();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:Compact2MutexEventProvider.java

示例10: readAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
@Override
public <T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException {
    return handle();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:Compact2MutexEventProvider.java

示例11: writeAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
<T> T writeAccess(Mutex.ExceptionAction<T> action) throws MutexException; 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:2,代码来源:MutexImplementation.java

示例12: readAccess

import org.openide.util.Mutex; //导入方法依赖的package包/类
<T> T readAccess(Mutex.ExceptionAction<T> action) throws MutexException; 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:2,代码来源:MutexImplementation.java


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