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


Java FutureTask.isCancelled方法代码示例

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


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

示例1: afterExecute

import java.util.concurrent.FutureTask; //导入方法依赖的package包/类
@Override
protected void afterExecute(Runnable task, Throwable exception) {
  if (task instanceof FutureTask<?>) {
    FutureTask<?> futureTask = (FutureTask<?>) task;
    if (!futureTask.isCancelled()) {
      try {
        futureTask.get();
      } catch (ExecutionException ee) {
        exception = ee.getCause();
      } catch (InterruptedException ie) {
        exception = ie;
      }
    }
  }
  if (exception != null) {
    LOG.error("Exception during execution of task in DeletionService",
      exception);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:DeletionService.java

示例2: drawContents

import java.util.concurrent.FutureTask; //导入方法依赖的package包/类
@Override
public void drawContents(TimeGraphTreeRender treeRender, TimeRange timeRange,
        VerticalPosition vPos, @Nullable FutureTask<?> task) {

    final long resolution = Math.max(1, Math.round(getWidget().getCurrentNanosPerPixel()));
    final List<TimeGraphTreeElement> allTreeElements = treeRender.getAllTreeElements();
    final int nbElements = allTreeElements.size();
    final int entriesToPrefetch = getWidget().getDebugOptions().entryPadding.get();
    final int topEntry = Math.max(0,
            TimeGraphWidget.paneYPosToEntryListIndex(vPos.fTopPos, TimeGraphWidget.ENTRY_HEIGHT) - entriesToPrefetch);
    final int bottomEntry = Math.min(nbElements,
            TimeGraphWidget.paneYPosToEntryListIndex(vPos.fBottomPos, TimeGraphWidget.ENTRY_HEIGHT) + entriesToPrefetch);

    LOGGER.finest(() -> "topEntry=" + topEntry +", bottomEntry=" + bottomEntry);

    List<TimeGraphStateRender> stateRenders = allTreeElements.subList(topEntry, bottomEntry).stream()
            .map(treeElem -> fStateProvider.getStateRender(treeElem, timeRange, resolution, task))
            .collect(Collectors.toList());

    if (task != null && task.isCancelled()) {
        return;
    }

    Collection<StateRectangle> stateRectangles = prepareStateRectangles(stateRenders, topEntry);
    Node statesLayerContents = prepareTimeGraphStatesContents(stateRectangles);
    Node labelsLayerContents = prepareTimeGrahLabelsContents(stateRectangles, fWindowRange);

    /*
     * Go over all state rectangles, and bring the "multi-state"
     * ones to the front, to be sure they show on top of the others.
     * Note we cannot do the forEach() as part of the stream, that
     * would throw a ConcurrentModificationException.
     */
    ((Group) statesLayerContents).getChildren().stream()
            .map(node -> (StateRectangle) node)
            .filter(rect -> (rect.getStateInterval().isMultiState()))
            .collect(Collectors.toList())
            .forEach(Node::toFront);

    Platform.runLater(() -> {
        getParentGroup().getChildren().clear();
        getLabelGroup().getChildren().clear();

        getParentGroup().getChildren().add(statesLayerContents);
        getLabelGroup().getChildren().add(labelsLayerContents);
    });
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:48,代码来源:TimeGraphStateLayer.java

示例3: run

import java.util.concurrent.FutureTask; //导入方法依赖的package包/类
static <V> void run(FutureTask<V> task) {
    boolean isCancelled = task.isCancelled();
    task.run();
    check(task.isDone());
    equal(isCancelled, task.isCancelled());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:Customized.java


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