hudson.model.Executor.isActive()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中hudson.model.Executor.isActive()方法的一些代码示例,展示了Executor.isActive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executor.isActive()方法的具体详情如下:
包路径:hudson.model.Executor
类名称:Executor
方法名:isActive

Executor.isActive介绍

[英]Check if executor is ready to accept tasks. This method becomes the critical one since 1.536, which introduces the on-demand creation of executor threads. Callers should use this method instead of #isAlive(), which would be incorrect for non-started threads or running AsynchronousExecution.
[中]检查执行者是否准备好接受任务。自1.536引入按需创建执行器线程以来,该方法成为关键方法。调用方应该使用此方法而不是#isAlive(),这对于未启动的线程或运行AsynchronousExecution是不正确的。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns true if any of the executors are {@linkplain Executor#isActive active}.
 *
 * @since 1.509
 */
protected boolean isAlive() {
  for (Executor e : executors)
    if (e.isActive())
      return true;
  return false;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Returns true if any of the executors are {@linkplain Executor#isActive active}.
 *
 * @since 1.509
 */
protected boolean isAlive() {
  for (Executor e : executors)
    if (e.isActive())
      return true;
  return false;
}

代码示例来源:origin: jenkinsci/workflow-cps-plugin

private void liveness() {
  assertFalse(jenkins().toComputer().isIdle());
  Executor e = b.getOneOffExecutor();
  assertNotNull(e);
  assertEquals(e, b.getExecutor());
  assertTrue(e.isActive());
  /* TODO seems flaky:
  assertFalse(e.isAlive());
  */
}

相关文章