java.util.concurrent.ForkJoinPool.deregisterWorker()方法的使用及代码示例

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

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

ForkJoinPool.deregisterWorker介绍

[英]Final callback from terminating worker, as well as upon failure to construct or start a worker. Removes record of worker from array, and adjusts counts. If pool is shutting down, tries to complete termination.
[中]终止工作进程的最终回调,以及构造或启动工作进程失败时的最终回调。从数组中删除辅助进程的记录,并调整计数。如果池正在关闭,则尝试完成终止。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Tries to create and start one worker if fewer than target
 * parallelism level exist. Adjusts counts etc on failure.
 */
private void tryAddWorker() {
  long c; int u;
  while ((u = (int)((c = ctl) >>> 32)) < 0 &&
      (u & SHORT_SIGN) != 0 && (int)c == 0) {
    long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
             ((u + UAC_UNIT) & UAC_MASK)) << 32;
    if (U.compareAndSwapLong(this, CTL, c, nc)) {
      ForkJoinWorkerThreadFactory fac;
      Throwable ex = null;
      ForkJoinWorkerThread wt = null;
      try {
        if ((fac = factory) != null &&
          (wt = fac.newThread(this)) != null) {
          wt.start();
          break;
        }
      } catch (Throwable e) {
        ex = e;
      }
      deregisterWorker(wt, ex);
      break;
    }
  }
}

代码示例来源:origin: robovm/robovm

ex = rex;
deregisterWorker(wt, ex); // clean up and return false

代码示例来源:origin: robovm/robovm

/**
   * This method is required to be public, but should never be
   * called explicitly. It performs the main run loop to execute
   * {@link ForkJoinTask}s.
   */
  public void run() {
    Throwable exception = null;
    try {
      onStart();
      pool.runWorker(workQueue);
    } catch (Throwable ex) {
      exception = ex;
    } finally {
      try {
        onTermination(exception);
      } catch (Throwable ex) {
        if (exception == null)
          exception = ex;
      } finally {
        pool.deregisterWorker(this, exception);
      }
    }
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * Tries to create and start one worker if fewer than target
 * parallelism level exist. Adjusts counts etc on failure.
 */
private void tryAddWorker() {
  long c; int u;
  while ((u = (int)((c = ctl) >>> 32)) < 0 &&
      (u & SHORT_SIGN) != 0 && (int)c == 0) {
    long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
             ((u + UAC_UNIT) & UAC_MASK)) << 32;
    if (U.compareAndSwapLong(this, CTL, c, nc)) {
      ForkJoinWorkerThreadFactory fac;
      Throwable ex = null;
      ForkJoinWorkerThread wt = null;
      try {
        if ((fac = factory) != null &&
          (wt = fac.newThread(this)) != null) {
          wt.start();
          break;
        }
      } catch (Throwable e) {
        ex = e;
      }
      deregisterWorker(wt, ex);
      break;
    }
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Tries to create and start one worker if fewer than target
 * parallelism level exist. Adjusts counts etc on failure.
 */
private void tryAddWorker() {
  long c; int u;
  while ((u = (int)((c = ctl) >>> 32)) < 0 &&
      (u & SHORT_SIGN) != 0 && (int)c == 0) {
    long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
             ((u + UAC_UNIT) & UAC_MASK)) << 32;
    if (U.compareAndSwapLong(this, CTL, c, nc)) {
      ForkJoinWorkerThreadFactory fac;
      Throwable ex = null;
      ForkJoinWorkerThread wt = null;
      try {
        if ((fac = factory) != null &&
          (wt = fac.newThread(this)) != null) {
          wt.start();
          break;
        }
      } catch (Throwable e) {
        ex = e;
      }
      deregisterWorker(wt, ex);
      break;
    }
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Tries to create and start one worker if fewer than target
 * parallelism level exist. Adjusts counts etc on failure.
 */
private void tryAddWorker() {
  long c; int u;
  while ((u = (int)((c = ctl) >>> 32)) < 0 &&
      (u & SHORT_SIGN) != 0 && (int)c == 0) {
    long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
             ((u + UAC_UNIT) & UAC_MASK)) << 32;
    if (U.compareAndSwapLong(this, CTL, c, nc)) {
      ForkJoinWorkerThreadFactory fac;
      Throwable ex = null;
      ForkJoinWorkerThread wt = null;
      try {
        if ((fac = factory) != null &&
          (wt = fac.newThread(this)) != null) {
          wt.start();
          break;
        }
      } catch (Throwable e) {
        ex = e;
      }
      deregisterWorker(wt, ex);
      break;
    }
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Tries to create and start one worker if fewer than target
 * parallelism level exist. Adjusts counts etc on failure.
 */
private void tryAddWorker() {
  long c; int u;
  while ((u = (int)((c = ctl) >>> 32)) < 0 &&
      (u & SHORT_SIGN) != 0 && (int)c == 0) {
    long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
             ((u + UAC_UNIT) & UAC_MASK)) << 32;
    if (U.compareAndSwapLong(this, CTL, c, nc)) {
      ForkJoinWorkerThreadFactory fac;
      Throwable ex = null;
      ForkJoinWorkerThread wt = null;
      try {
        if ((fac = factory) != null &&
          (wt = fac.newThread(this)) != null) {
          wt.start();
          break;
        }
      } catch (Throwable e) {
        ex = e;
      }
      deregisterWorker(wt, ex);
      break;
    }
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * Tries to create and start one worker if fewer than target
 * parallelism level exist. Adjusts counts etc on failure.
 */
private void tryAddWorker() {
  long c; int u;
  while ((u = (int)((c = ctl) >>> 32)) < 0 &&
      (u & SHORT_SIGN) != 0 && (int)c == 0) {
    long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
             ((u + UAC_UNIT) & UAC_MASK)) << 32;
    if (U.compareAndSwapLong(this, CTL, c, nc)) {
      ForkJoinWorkerThreadFactory fac;
      Throwable ex = null;
      ForkJoinWorkerThread wt = null;
      try {
        if ((fac = factory) != null &&
          (wt = fac.newThread(this)) != null) {
          wt.start();
          break;
        }
      } catch (Throwable e) {
        ex = e;
      }
      deregisterWorker(wt, ex);
      break;
    }
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Performs cleanup associated with termination of this worker
 * thread.  If you override this method, you must invoke
 * {@code super.onTermination} at the end of the overridden method.
 *
 * @param exception the exception causing this thread to abort due
 * to an unrecoverable error, or {@code null} if completed normally
 */
protected void onTermination(Throwable exception) {
  try {
    terminate = true;
    cancelTasks();
    pool.deregisterWorker(this, exception);
  } catch (Throwable ex) {        // Shouldn't ever happen
    if (exception == null)      // but if so, at least rethrown
      exception = ex;
  } finally {
    if (exception != null)
      UNSAFE.throwException(exception);
  }
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Performs cleanup associated with termination of this worker
 * thread.  If you override this method, you must invoke
 * {@code super.onTermination} at the end of the overridden method.
 *
 * @param exception the exception causing this thread to abort due
 * to an unrecoverable error, or {@code null} if completed normally
 */
protected void onTermination(Throwable exception) {
  try {
    terminate = true;
    cancelTasks();
    pool.deregisterWorker(this, exception);
  } catch (Throwable ex) {        // Shouldn't ever happen
    if (exception == null)      // but if so, at least rethrown
      exception = ex;
  } finally {
    if (exception != null)
      UNSAFE.throwException(exception);
  }
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
 * Performs cleanup associated with termination of this worker
 * thread.  If you override this method, you must invoke
 * {@code super.onTermination} at the end of the overridden method.
 *
 * @param exception the exception causing this thread to abort due
 * to an unrecoverable error, or {@code null} if completed normally
 */
protected void onTermination(Throwable exception) {
  try {
    terminate = true;
    cancelTasks();
    pool.deregisterWorker(this, exception);
  } catch (Throwable ex) {        // Shouldn't ever happen
    if (exception == null)      // but if so, at least rethrown
      exception = ex;
  } finally {
    if (exception != null)
      UNSAFE.throwException(exception);
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Tries to create and start one worker if fewer than target
 * parallelism level exist. Adjusts counts etc on failure.
 */
private void tryAddWorker() {
  long c; int u;
  while ((u = (int)((c = ctl) >>> 32)) < 0 &&
      (u & SHORT_SIGN) != 0 && (int)c == 0) {
    long nc = (long)(((u + UTC_UNIT) & UTC_MASK) |
             ((u + UAC_UNIT) & UAC_MASK)) << 32;
    if (U.compareAndSwapLong(this, CTL, c, nc)) {
      ForkJoinWorkerThreadFactory fac;
      Throwable ex = null;
      ForkJoinWorkerThread wt = null;
      try {
        if ((fac = factory) != null &&
          (wt = fac.newThread(this)) != null) {
          wt.start();
          break;
        }
      } catch (Throwable e) {
        ex = e;
      }
      deregisterWorker(wt, ex);
      break;
    }
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

ex = rex;
deregisterWorker(wt, ex); // clean up and return false

代码示例来源:origin: ibinti/bugvm

ex = rex;
deregisterWorker(wt, ex); // clean up and return false

代码示例来源:origin: MobiVM/robovm

/**
   * This method is required to be public, but should never be
   * called explicitly. It performs the main run loop to execute
   * {@link ForkJoinTask}s.
   */
  public void run() {
    Throwable exception = null;
    try {
      onStart();
      pool.runWorker(workQueue);
    } catch (Throwable ex) {
      exception = ex;
    } finally {
      try {
        onTermination(exception);
      } catch (Throwable ex) {
        if (exception == null)
          exception = ex;
      } finally {
        pool.deregisterWorker(this, exception);
      }
    }
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
   * This method is required to be public, but should never be
   * called explicitly. It performs the main run loop to execute
   * {@link ForkJoinTask}s.
   */
  public void run() {
    Throwable exception = null;
    try {
      onStart();
      pool.runWorker(workQueue);
    } catch (Throwable ex) {
      exception = ex;
    } finally {
      try {
        onTermination(exception);
      } catch (Throwable ex) {
        if (exception == null)
          exception = ex;
      } finally {
        pool.deregisterWorker(this, exception);
      }
    }
  }
}

代码示例来源:origin: ibinti/bugvm

/**
   * This method is required to be public, but should never be
   * called explicitly. It performs the main run loop to execute
   * {@link ForkJoinTask}s.
   */
  public void run() {
    Throwable exception = null;
    try {
      onStart();
      pool.runWorker(workQueue);
    } catch (Throwable ex) {
      exception = ex;
    } finally {
      try {
        onTermination(exception);
      } catch (Throwable ex) {
        if (exception == null)
          exception = ex;
      } finally {
        pool.deregisterWorker(this, exception);
      }
    }
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
   * This method is required to be public, but should never be
   * called explicitly. It performs the main run loop to execute
   * {@link ForkJoinTask}s.
   */
  public void run() {
    Throwable exception = null;
    try {
      onStart();
      pool.runWorker(workQueue);
    } catch (Throwable ex) {
      exception = ex;
    } finally {
      try {
        onTermination(exception);
      } catch (Throwable ex) {
        if (exception == null)
          exception = ex;
      } finally {
        pool.deregisterWorker(this, exception);
      }
    }
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
   * This method is required to be public, but should never be
   * called explicitly. It performs the main run loop to execute
   * {@link ForkJoinTask}s.
   */
  public void run() {
    Throwable exception = null;
    try {
      onStart();
      pool.runWorker(workQueue);
    } catch (Throwable ex) {
      exception = ex;
    } finally {
      try {
        onTermination(exception);
      } catch (Throwable ex) {
        if (exception == null)
          exception = ex;
      } finally {
        pool.deregisterWorker(this, exception);
      }
    }
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
   * This method is required to be public, but should never be
   * called explicitly. It performs the main run loop to execute
   * {@link ForkJoinTask}s.
   */
  public void run() {
    Throwable exception = null;
    try {
      onStart();
      pool.runWorker(workQueue);
    } catch (Throwable ex) {
      exception = ex;
    } finally {
      try {
        onTermination(exception);
      } catch (Throwable ex) {
        if (exception == null)
          exception = ex;
      } finally {
        pool.deregisterWorker(this, exception);
      }
    }
  }
}

相关文章

ForkJoinPool类方法