本文整理了Java中java.util.concurrent.ForkJoinPool.signalWork()
方法的一些代码示例,展示了ForkJoinPool.signalWork()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ForkJoinPool.signalWork()
方法的具体详情如下:
包路径:java.util.concurrent.ForkJoinPool
类名称:ForkJoinPool
方法名:signalWork
[英]Wakes up or creates a worker.
[中]唤醒或创建一个工作者。
代码示例来源:origin: robovm/robovm
/**
* Returns a (probably) non-empty steal queue, if one is found
* during a random, then cyclic scan, else null. This method must
* be retried by caller if, by the time it tries to use the queue,
* it is empty.
* @param r a (random) seed for scanning
*/
private WorkQueue findNonEmptyStealQueue(int r) {
for (WorkQueue[] ws;;) {
int ps = plock, m, n;
if ((ws = workQueues) == null || (m = ws.length - 1) < 1)
return null;
for (int j = (m + 1) << 2; ;) {
WorkQueue q = ws[(((r + j) << 1) | 1) & m];
if (q != null && (n = q.base - q.top) < 0) {
if (n < -1)
signalWork(q);
return q;
}
else if (--j < 0) {
if (plock == ps)
return null;
break;
}
}
}
}
代码示例来源:origin: robovm/robovm
/**
* Pushes a task. Call only by owner in unshared queues. (The
* shared-queue version is embedded in method externalPush.)
*
* @param task the task. Caller must ensure non-null.
* @throws RejectedExecutionException if array cannot be resized
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int s = top, m, n;
if ((a = array) != null) { // ignore if queue removed
int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
U.putOrderedObject(a, j, task);
if ((n = (top = s + 1) - base) <= 2) {
if ((p = pool) != null)
p.signalWork(this);
}
else if (n >= m)
growArray();
}
}
代码示例来源: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: robovm/robovm
U.compareAndSwapObject(a, i, t, null)) {
if ((q.base = b + 1) - q.top < 0)
signalWork(q);
return t; // taken
代码示例来源:origin: robovm/robovm
return;
if ((q = ws[i]) != null && q.base - q.top < 0) {
p.signalWork(q);
if ((u = (int)(p.ctl >>> 32)) >= 0 ||
(u >> UAC_SHIFT) >= 0)
代码示例来源:origin: robovm/robovm
signalWork(q);
return;
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Returns a (probably) non-empty steal queue, if one is found
* during a random, then cyclic scan, else null. This method must
* be retried by caller if, by the time it tries to use the queue,
* it is empty.
* @param r a (random) seed for scanning
*/
private WorkQueue findNonEmptyStealQueue(int r) {
for (WorkQueue[] ws;;) {
int ps = plock, m, n;
if ((ws = workQueues) == null || (m = ws.length - 1) < 1)
return null;
for (int j = (m + 1) << 2; ;) {
WorkQueue q = ws[(((r + j) << 1) | 1) & m];
if (q != null && (n = q.base - q.top) < 0) {
if (n < -1)
signalWork(q);
return q;
}
else if (--j < 0) {
if (plock == ps)
return null;
break;
}
}
}
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Enqueues the given task in the submissionQueue. Same idea as
* ForkJoinWorkerThread.pushTask except for use of submissionLock.
*
* @param t the task
*/
private void addSubmission(ForkJoinTask<?> t) {
final ReentrantLock lock = this.submissionLock;
lock.lock();
try {
ForkJoinTask<?>[] q; int s, m;
if ((q = submissionQueue) != null) { // ignore if queue removed
long u = (((s = queueTop) & (m = q.length-1)) << ASHIFT)+ABASE;
UNSAFE.putOrderedObject(q, u, t);
queueTop = s + 1;
if (s - queueBase == m)
growSubmissionQueue();
}
} finally {
lock.unlock();
}
signalWork();
}
代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166
/**
* Enqueues the given task in the submissionQueue. Same idea as
* ForkJoinWorkerThread.pushTask except for use of submissionLock.
*
* @param t the task
*/
private void addSubmission(ForkJoinTask<?> t) {
final ReentrantLock lock = this.submissionLock;
lock.lock();
try {
ForkJoinTask<?>[] q; int s, m;
if ((q = submissionQueue) != null) { // ignore if queue removed
long u = (((s = queueTop) & (m = q.length-1)) << ASHIFT)+ABASE;
UNSAFE.putOrderedObject(q, u, t);
queueTop = s + 1;
if (s - queueBase == m)
growSubmissionQueue();
}
} finally {
lock.unlock();
}
signalWork();
}
代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166
/**
* Pushes a task. Call only from this thread.
*
* @param t the task. Caller must ensure non-null.
*/
final void pushTask(ForkJoinTask<?> t) {
ForkJoinTask<?>[] q; int s, m;
if ((q = queue) != null) { // ignore if queue removed
long u = (((s = queueTop) & (m = q.length - 1)) << ASHIFT) + ABASE;
UNSAFE.putOrderedObject(q, u, t);
queueTop = s + 1; // or use putOrderedInt
if ((s -= queueBase) <= 2)
pool.signalWork();
else if (s == m)
growQueue();
}
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Pushes a task. Call only from this thread.
*
* @param t the task. Caller must ensure non-null.
*/
final void pushTask(ForkJoinTask<?> t) {
ForkJoinTask<?>[] q; int s, m;
if ((q = queue) != null) { // ignore if queue removed
long u = (((s = queueTop) & (m = q.length - 1)) << ASHIFT) + ABASE;
UNSAFE.putOrderedObject(q, u, t);
queueTop = s + 1; // or use putOrderedInt
if ((s -= queueBase) <= 2)
pool.signalWork();
else if (s == m)
growQueue();
}
}
代码示例来源:origin: ibinti/bugvm
/**
* Pushes a task. Call only by owner in unshared queues. (The
* shared-queue version is embedded in method externalPush.)
*
* @param task the task. Caller must ensure non-null.
* @throws RejectedExecutionException if array cannot be resized
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int s = top, m, n;
if ((a = array) != null) { // ignore if queue removed
int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
U.putOrderedObject(a, j, task);
if ((n = (top = s + 1) - base) <= 2) {
if ((p = pool) != null)
p.signalWork(this);
}
else if (n >= m)
growArray();
}
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Pushes a task. Call only from this thread.
*
* @param t the task. Caller must ensure non-null.
*/
final void pushTask(ForkJoinTask<?> t) {
ForkJoinTask<?>[] q; int s, m;
if ((q = queue) != null) { // ignore if queue removed
long u = (((s = queueTop) & (m = q.length - 1)) << ASHIFT) + ABASE;
UNSAFE.putOrderedObject(q, u, t);
queueTop = s + 1; // or use putOrderedInt
if ((s -= queueBase) <= 2)
pool.signalWork();
else if (s == m)
growQueue();
}
}
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* Pushes a task. Call only by owner in unshared queues. (The
* shared-queue version is embedded in method externalPush.)
*
* @param task the task. Caller must ensure non-null.
* @throws RejectedExecutionException if array cannot be resized
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int s = top, m, n;
if ((a = array) != null) { // ignore if queue removed
int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
U.putOrderedObject(a, j, task);
if ((n = (top = s + 1) - base) <= 2) {
if ((p = pool) != null)
p.signalWork(this);
}
else if (n >= m)
growArray();
}
}
代码示例来源:origin: MobiVM/robovm
/**
* Pushes a task. Call only by owner in unshared queues. (The
* shared-queue version is embedded in method externalPush.)
*
* @param task the task. Caller must ensure non-null.
* @throws RejectedExecutionException if array cannot be resized
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int s = top, m, n;
if ((a = array) != null) { // ignore if queue removed
int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
U.putOrderedObject(a, j, task);
if ((n = (top = s + 1) - base) <= 2) {
if ((p = pool) != null)
p.signalWork(this);
}
else if (n >= m)
growArray();
}
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Pushes a task. Call only by owner in unshared queues. (The
* shared-queue version is embedded in method externalPush.)
*
* @param task the task. Caller must ensure non-null.
* @throws RejectedExecutionException if array cannot be resized
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int s = top, m, n;
if ((a = array) != null) { // ignore if queue removed
int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
U.putOrderedObject(a, j, task);
if ((n = (top = s + 1) - base) <= 2) {
if ((p = pool) != null)
p.signalWork(this);
}
else if (n >= m)
growArray();
}
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Pushes a task. Call only by owner in unshared queues. (The
* shared-queue version is embedded in method externalPush.)
*
* @param task the task. Caller must ensure non-null.
* @throws RejectedExecutionException if array cannot be resized
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int s = top, m, n;
if ((a = array) != null) { // ignore if queue removed
int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
U.putOrderedObject(a, j, task);
if ((n = (top = s + 1) - base) <= 2) {
if ((p = pool) != null)
p.signalWork(this);
}
else if (n >= m)
growArray();
}
}
代码示例来源:origin: FlexoVM/flexovm
/**
* Pushes a task. Call only by owner in unshared queues. (The
* shared-queue version is embedded in method externalPush.)
*
* @param task the task. Caller must ensure non-null.
* @throws RejectedExecutionException if array cannot be resized
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int s = top, m, n;
if ((a = array) != null) { // ignore if queue removed
int j = (((m = a.length - 1) & s) << ASHIFT) + ABASE;
U.putOrderedObject(a, j, task);
if ((n = (top = s + 1) - base) <= 2) {
if ((p = pool) != null)
p.signalWork(this);
}
else if (n >= m)
growArray();
}
}
代码示例来源: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: 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);
}
内容来源于网络,如有侵权,请联系作者删除!