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


Java SharedExecutorService类代码示例

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


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

示例1: AnalyzerResultFutureImpl

import org.apache.metamodel.util.SharedExecutorService; //导入依赖的package包/类
/**
 * Constructs an {@link AnalyzerResultFutureImpl}
 *
 * @param name
 *            a name/label to use for presenting and distinguishing this
 *            result from others.
 * @param resultRef
 *            a reference for the result being processed.
 */
public AnalyzerResultFutureImpl(final String name, final Supplier<? extends R> resultRef) {
    _name = name;
    _countDownLatch = new CountDownLatch(1);
    _result = null;
    _error = null;

    SharedExecutorService.get().submit(() -> {
        try {
            _result = resultRef.get();
            if (_result == null && resultRef instanceof LazyRef) {
                // TODO: workaround - reported as MM bug, remove when
                // fixed.
                throw new RuntimeException(((LazyRef<?>) resultRef).getError());
            }
            onSuccess();
        } catch (final RuntimeException e) {
            _error = e;
            onError();
        } finally {
            _countDownLatch.countDown();
        }
    });
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:33,代码来源:AnalyzerResultFutureImpl.java

示例2: AnalyzerResultFuture

import org.apache.metamodel.util.SharedExecutorService; //导入依赖的package包/类
/**
 * Constructs an {@link AnalyzerResultFuture}
 * 
 * @param name
 *            a name/label to use for presenting and distinguishing this
 *            result from others.
 * @param resultRef
 *            a reference for the result being processed.
 */
public AnalyzerResultFuture(String name, final Ref<? extends R> resultRef) {
    _name = name;
    _countDownLatch = new CountDownLatch(1);
    _result = null;
    _error = null;

    SharedExecutorService.get().submit(new Runnable() {

        @Override
        public void run() {
            try {
                _result = resultRef.get();
                onSuccess();
            } catch (RuntimeException e) {
                _error = e;
                onError();
            } finally {
                _countDownLatch.countDown();
            }
        }
    });
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:32,代码来源:AnalyzerResultFuture.java

示例3: next

import org.apache.metamodel.util.SharedExecutorService; //导入依赖的package包/类
@Override
public boolean next() {
    if (_rowPublisher == null) {
        // first time, create the publisher
        _rowPublisher = new RowPublisherImpl(this);
        logger.info("Starting separate thread for publishing action: {}", _publishAction);
        Runnable runnable = new Runnable() {
            public void run() {
                boolean successful = false;
                try {
                    _publishAction.run(_rowPublisher);
                    logger.debug("Publshing action finished!");
                    successful = true;
                } catch (Exception e) {
                    _rowPublisher.failed(e);
                }
                if (successful) {
                    _rowPublisher.finished();
                }
            };
        };
        SharedExecutorService.get().submit(runnable);
    }
    return _rowPublisher.next();
}
 
开发者ID:apache,项目名称:metamodel,代码行数:26,代码来源:RowPublisherDataSet.java

示例4: awaitAndInformListener

import org.apache.metamodel.util.SharedExecutorService; //导入依赖的package包/类
/**
 * Spawns a new thread for awaiting the result future (which will force the
 * reducer to inform about the progress).
 *
 * @param job
 * @param analysisJobMetrics
 * @param resultFuture
 */
private void awaitAndInformListener(final AnalysisJob job, final AnalysisJobMetrics analysisJobMetrics,
        final RowProcessingMetrics rowProcessingMetrics, final AnalysisResultFuture resultFuture) {
    SharedExecutorService.get().execute(() -> {
        resultFuture.await();
        if (resultFuture.isSuccessful()) {
            _analysisListener.jobSuccess(job, analysisJobMetrics);
        }
    });
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:18,代码来源:DistributedAnalysisRunner.java

示例5: updateCategories

import org.apache.metamodel.util.SharedExecutorService; //导入依赖的package包/类
private void updateCategories() {
    SharedExecutorService.get().submit((Runnable) () -> {
        final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Categories");
        _client.refreshCategories();
        final Collection<Category> categories = _client.getCategories();
        for (final Category category : categories) {
            final DefaultMutableTreeNode categoryNode = new DefaultMutableTreeNode(category);
            rootNode.add(categoryNode);
        }

        final TreeModel treeModel = new DefaultTreeModel(rootNode);
        _categoryTree.setModel(treeModel);
    });
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:15,代码来源:RegexSwapDialog.java

示例6: awaitAndInformListener

import org.apache.metamodel.util.SharedExecutorService; //导入依赖的package包/类
/**
 * Spawns a new thread for awaiting the result future (which will force the
 * reducer to inform about the progress).
 * 
 * @param job
 * @param analysisJobMetrics
 * @param resultFuture
 */
private void awaitAndInformListener(final AnalysisJob job, final AnalysisJobMetrics analysisJobMetrics,
        final RowProcessingMetrics rowProcessingMetrics, final AnalysisResultFuture resultFuture) {
    SharedExecutorService.get().execute(new Runnable() {
        @Override
        public void run() {
            resultFuture.await();
            if (resultFuture.isSuccessful()) {
                _analysisListener.jobSuccess(job, analysisJobMetrics);
            }
        }
    });
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:21,代码来源:DistributedAnalysisRunner.java


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