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

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

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

ForkJoinPool.externalPush介绍

[英]Unless shutting down, adds the given task to a submission queue at submitter's current queue index (modulo submission range). Only the most common path is directly handled in this method. All others are relayed to fullExternalPush.
[中]除非关闭,否则会将给定任务添加到提交者当前队列索引(模提交范围)处的提交队列中。此方法仅直接处理最常见的路径。所有其他的都被中继到fullExternalPush。

代码示例

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

/**
 * Arranges for (asynchronous) execution of the given task.
 *
 * @param task the task
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public void execute(ForkJoinTask<?> task) {
  if (task == null)
    throw new NullPointerException();
  externalPush(task);
}

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

/**
 * Submits a ForkJoinTask for execution.
 *
 * @param task the task to submit
 * @return the task
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(ForkJoinTask<T> task) {
  if (task == null)
    throw new NullPointerException();
  externalPush(task);
  return task;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Runnable task, T result) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedRunnable<T>(task, result);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Callable<T> task) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedCallable<T>(task);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public ForkJoinTask<?> submit(Runnable task) {
  if (task == null)
    throw new NullPointerException();
  ForkJoinTask<?> job;
  if (task instanceof ForkJoinTask<?>) // avoid re-wrap
    job = (ForkJoinTask<?>) task;
  else
    job = new ForkJoinTask.AdaptedRunnableAction(task);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public void execute(Runnable task) {
  if (task == null)
    throw new NullPointerException();
  ForkJoinTask<?> job;
  if (task instanceof ForkJoinTask<?>) // avoid re-wrap
    job = (ForkJoinTask<?>) task;
  else
    job = new ForkJoinTask.AdaptedRunnableAction(task);
  externalPush(job);
}

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

/**
 * Performs the given task, returning its result upon completion.
 * If the computation encounters an unchecked Exception or Error,
 * it is rethrown as the outcome of this invocation.  Rethrown
 * exceptions behave in the same way as regular exceptions, but,
 * when possible, contain stack traces (as displayed for example
 * using {@code ex.printStackTrace()}) of both the current thread
 * as well as the thread actually encountering the exception;
 * minimally only the latter.
 *
 * @param task the task
 * @return the task's result
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> T invoke(ForkJoinTask<T> task) {
  if (task == null)
    throw new NullPointerException();
  externalPush(task);
  return task.join();
}

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

/**
 * Arranges to asynchronously execute this task in the pool the
 * current task is running in, if applicable, or using the {@link
 * ForkJoinPool#commonPool()} if not {@link #inForkJoinPool}.  While
 * it is not necessarily enforced, it is a usage error to fork a
 * task more than once unless it has completed and been
 * reinitialized.  Subsequent modifications to the state of this
 * task or any data it operates on are not necessarily
 * consistently observable by any thread other than the one
 * executing it unless preceded by a call to {@link #join} or
 * related methods, or a call to {@link #isDone} returning {@code
 * true}.
 *
 * @return {@code this}, to simplify usage
 */
public final ForkJoinTask<V> fork() {
  Thread t;
  if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
    ((ForkJoinWorkerThread)t).workQueue.push(this);
  else
    ForkJoinPool.commonPool.externalPush(this);
  return this;
}

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

/**
 * @throws NullPointerException       {@inheritDoc}
 * @throws RejectedExecutionException {@inheritDoc}
 */
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) {
  // In previous versions of this class, this method constructed
  // a task to run ForkJoinTask.invokeAll, but now external
  // invocation of multiple tasks is at least as efficient.
  ArrayList<Future<T>> futures = new ArrayList<Future<T>>(tasks.size());
  boolean done = false;
  try {
    for (Callable<T> t : tasks) {
      ForkJoinTask<T> f = new ForkJoinTask.AdaptedCallable<T>(t);
      futures.add(f);
      externalPush(f);
    }
    for (int i = 0, size = futures.size(); i < size; i++)
      ((ForkJoinTask<?>)futures.get(i)).quietlyJoin();
    done = true;
    return futures;
  } finally {
    if (!done)
      for (int i = 0, size = futures.size(); i < size; i++)
        futures.get(i).cancel(false);
  }
}

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

/**
 * Arranges for (asynchronous) execution of the given task.
 *
 * @param task the task
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public void execute(ForkJoinTask<?> task) {
  if (task == null)
    throw new NullPointerException();
  externalPush(task);
}

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

/**
 * Arranges for (asynchronous) execution of the given task.
 *
 * @param task the task
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public void execute(ForkJoinTask<?> task) {
  if (task == null)
    throw new NullPointerException();
  externalPush(task);
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Callable<T> task) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedCallable<T>(task);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Runnable task, T result) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedRunnable<T>(task, result);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Runnable task, T result) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedRunnable<T>(task, result);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Callable<T> task) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedCallable<T>(task);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Runnable task, T result) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedRunnable<T>(task, result);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Callable<T> task) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedCallable<T>(task);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Runnable task, T result) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedRunnable<T>(task, result);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Callable<T> task) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedCallable<T>(task);
  externalPush(job);
  return job;
}

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

/**
 * @throws NullPointerException if the task is null
 * @throws RejectedExecutionException if the task cannot be
 *         scheduled for execution
 */
public <T> ForkJoinTask<T> submit(Callable<T> task) {
  ForkJoinTask<T> job = new ForkJoinTask.AdaptedCallable<T>(task);
  externalPush(job);
  return job;
}

相关文章

ForkJoinPool类方法