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

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

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

ForkJoinPool.fullExternalPush介绍

[英]Full version of externalPush. This method is called, among other times, upon the first submission of the first task to the pool, so must perform secondary initialization (via initWorkers). It also detects first submission by an external thread by looking up its ThreadLocal, and creates a new shared queue if the one at index if empty or contended. The plock lock body must be exception-free (so no try/finally) so we optimistically allocate new queues outside the lock and throw them away if (very rarely) not needed.
[中]

代码示例

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

/**
 * 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.
 *
 * @param task the task. Caller must ensure non-null.
 */
final void externalPush(ForkJoinTask<?> task) {
  WorkQueue[] ws; WorkQueue q; Submitter z; int m; ForkJoinTask<?>[] a;
  if ((z = submitters.get()) != null && plock > 0 &&
    (ws = workQueues) != null && (m = (ws.length - 1)) >= 0 &&
    (q = ws[m & z.seed & SQMASK]) != null &&
    U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
    int b = q.base, s = q.top, n, an;
    if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
      int j = (((an - 1) & s) << ASHIFT) + ABASE;
      U.putOrderedObject(a, j, task);
      q.top = s + 1;                     // push on to deque
      q.qlock = 0;
      if (n <= 2)
        signalWork(q);
      return;
    }
    q.qlock = 0;
  }
  fullExternalPush(task);
}

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

/**
 * 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.
 *
 * @param task the task. Caller must ensure non-null.
 */
final void externalPush(ForkJoinTask<?> task) {
  WorkQueue[] ws; WorkQueue q; Submitter z; int m; ForkJoinTask<?>[] a;
  if ((z = submitters.get()) != null && plock > 0 &&
    (ws = workQueues) != null && (m = (ws.length - 1)) >= 0 &&
    (q = ws[m & z.seed & SQMASK]) != null &&
    U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
    int b = q.base, s = q.top, n, an;
    if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
      int j = (((an - 1) & s) << ASHIFT) + ABASE;
      U.putOrderedObject(a, j, task);
      q.top = s + 1;                     // push on to deque
      q.qlock = 0;
      if (n <= 2)
        signalWork(q);
      return;
    }
    q.qlock = 0;
  }
  fullExternalPush(task);
}

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

/**
 * 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.
 *
 * @param task the task. Caller must ensure non-null.
 */
final void externalPush(ForkJoinTask<?> task) {
  WorkQueue[] ws; WorkQueue q; Submitter z; int m; ForkJoinTask<?>[] a;
  if ((z = submitters.get()) != null && plock > 0 &&
    (ws = workQueues) != null && (m = (ws.length - 1)) >= 0 &&
    (q = ws[m & z.seed & SQMASK]) != null &&
    U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
    int b = q.base, s = q.top, n, an;
    if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
      int j = (((an - 1) & s) << ASHIFT) + ABASE;
      U.putOrderedObject(a, j, task);
      q.top = s + 1;                     // push on to deque
      q.qlock = 0;
      if (n <= 2)
        signalWork(q);
      return;
    }
    q.qlock = 0;
  }
  fullExternalPush(task);
}

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

/**
 * 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.
 *
 * @param task the task. Caller must ensure non-null.
 */
final void externalPush(ForkJoinTask<?> task) {
  WorkQueue[] ws; WorkQueue q; Submitter z; int m; ForkJoinTask<?>[] a;
  if ((z = submitters.get()) != null && plock > 0 &&
    (ws = workQueues) != null && (m = (ws.length - 1)) >= 0 &&
    (q = ws[m & z.seed & SQMASK]) != null &&
    U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
    int b = q.base, s = q.top, n, an;
    if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
      int j = (((an - 1) & s) << ASHIFT) + ABASE;
      U.putOrderedObject(a, j, task);
      q.top = s + 1;                     // push on to deque
      q.qlock = 0;
      if (n <= 2)
        signalWork(q);
      return;
    }
    q.qlock = 0;
  }
  fullExternalPush(task);
}

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

/**
 * 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.
 *
 * @param task the task. Caller must ensure non-null.
 */
final void externalPush(ForkJoinTask<?> task) {
  WorkQueue[] ws; WorkQueue q; Submitter z; int m; ForkJoinTask<?>[] a;
  if ((z = submitters.get()) != null && plock > 0 &&
    (ws = workQueues) != null && (m = (ws.length - 1)) >= 0 &&
    (q = ws[m & z.seed & SQMASK]) != null &&
    U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
    int b = q.base, s = q.top, n, an;
    if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
      int j = (((an - 1) & s) << ASHIFT) + ABASE;
      U.putOrderedObject(a, j, task);
      q.top = s + 1;                     // push on to deque
      q.qlock = 0;
      if (n <= 2)
        signalWork(q);
      return;
    }
    q.qlock = 0;
  }
  fullExternalPush(task);
}

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

/**
 * 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.
 *
 * @param task the task. Caller must ensure non-null.
 */
final void externalPush(ForkJoinTask<?> task) {
  WorkQueue[] ws; WorkQueue q; Submitter z; int m; ForkJoinTask<?>[] a;
  if ((z = submitters.get()) != null && plock > 0 &&
    (ws = workQueues) != null && (m = (ws.length - 1)) >= 0 &&
    (q = ws[m & z.seed & SQMASK]) != null &&
    U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
    int b = q.base, s = q.top, n, an;
    if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
      int j = (((an - 1) & s) << ASHIFT) + ABASE;
      U.putOrderedObject(a, j, task);
      q.top = s + 1;                     // push on to deque
      q.qlock = 0;
      if (n <= 2)
        signalWork(q);
      return;
    }
    q.qlock = 0;
  }
  fullExternalPush(task);
}

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

/**
 * 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.
 *
 * @param task the task. Caller must ensure non-null.
 */
final void externalPush(ForkJoinTask<?> task) {
  WorkQueue[] ws; WorkQueue q; Submitter z; int m; ForkJoinTask<?>[] a;
  if ((z = submitters.get()) != null && plock > 0 &&
    (ws = workQueues) != null && (m = (ws.length - 1)) >= 0 &&
    (q = ws[m & z.seed & SQMASK]) != null &&
    U.compareAndSwapInt(q, QLOCK, 0, 1)) { // lock
    int b = q.base, s = q.top, n, an;
    if ((a = q.array) != null && (an = a.length) > (n = s + 1 - b)) {
      int j = (((an - 1) & s) << ASHIFT) + ABASE;
      U.putOrderedObject(a, j, task);
      q.top = s + 1;                     // push on to deque
      q.qlock = 0;
      if (n <= 2)
        signalWork(q);
      return;
    }
    q.qlock = 0;
  }
  fullExternalPush(task);
}

相关文章

微信公众号

最新文章

更多

ForkJoinPool类方法