/** * Drains tasks to given collection c. * * @return the number of tasks drained */ final int drainTasksTo(Collection<? super ForkJoinTask<?>> c) { int n = 0; while (queueBase != queueTop) { ForkJoinTask<?> t = deqTask(); if (t != null) { c.add(t); ++n; } } return n; }
/** * Drains tasks to given collection c. * * @return the number of tasks drained */ final int drainTasksTo(Collection<? super ForkJoinTask<?>> c) { int n = 0; while (queueBase != queueTop) { ForkJoinTask<?> t = deqTask(); if (t != null) { c.add(t); ++n; } } return n; }
/** * Drains tasks to given collection c. * * @return the number of tasks drained */ final int drainTasksTo(Collection<? super ForkJoinTask<?>> c) { int n = 0; while (queueBase != queueTop) { ForkJoinTask<?> t = deqTask(); if (t != null) { c.add(t); ++n; } } return n; }
/** * Gets and removes a local or stolen task. * * @return a task, if available */ final ForkJoinTask<?> pollTask() { ForkJoinWorkerThread[] ws; ForkJoinTask<?> t = pollLocalTask(); if (t != null || (ws = pool.workers) == null) return t; int n = ws.length; // cheap version of FJP.scan int steps = n << 1; int r = nextSeed(); int i = 0; while (i < steps) { ForkJoinWorkerThread w = ws[(i++ + r) & (n - 1)]; if (w != null && w.queueBase != w.queueTop && w.queue != null) { if ((t = w.deqTask()) != null) return t; i = 0; } } return null; }
/** * Gets and removes a local or stolen task. * * @return a task, if available */ final ForkJoinTask<?> pollTask() { ForkJoinWorkerThread[] ws; ForkJoinTask<?> t = pollLocalTask(); if (t != null || (ws = pool.workers) == null) return t; int n = ws.length; // cheap version of FJP.scan int steps = n << 1; int r = nextSeed(); int i = 0; while (i < steps) { ForkJoinWorkerThread w = ws[(i++ + r) & (n - 1)]; if (w != null && w.queueBase != w.queueTop && w.queue != null) { if ((t = w.deqTask()) != null) return t; i = 0; } } return null; }
/** * Gets and removes a local or stolen task. * * @return a task, if available */ final ForkJoinTask<?> pollTask() { ForkJoinWorkerThread[] ws; ForkJoinTask<?> t = pollLocalTask(); if (t != null || (ws = pool.workers) == null) return t; int n = ws.length; // cheap version of FJP.scan int steps = n << 1; int r = nextSeed(); int i = 0; while (i < steps) { ForkJoinWorkerThread w = ws[(i++ + r) & (n - 1)]; if (w != null && w.queueBase != w.queueTop && w.queue != null) { if ((t = w.deqTask()) != null) return t; i = 0; } } return null; }
/** * Removes and cancels all tasks in queue. Can be called from any * thread. */ final void cancelTasks() { ForkJoinTask<?> cj = currentJoin; // try to cancel ongoing tasks if (cj != null && cj.status >= 0) cj.cancelIgnoringExceptions(); ForkJoinTask<?> cs = currentSteal; if (cs != null && cs.status >= 0) cs.cancelIgnoringExceptions(); while (queueBase != queueTop) { ForkJoinTask<?> t = deqTask(); if (t != null) t.cancelIgnoringExceptions(); } }
/** * Removes and cancels all tasks in queue. Can be called from any * thread. */ final void cancelTasks() { ForkJoinTask<?> cj = currentJoin; // try to cancel ongoing tasks if (cj != null && cj.status >= 0) cj.cancelIgnoringExceptions(); ForkJoinTask<?> cs = currentSteal; if (cs != null && cs.status >= 0) cs.cancelIgnoringExceptions(); while (queueBase != queueTop) { ForkJoinTask<?> t = deqTask(); if (t != null) t.cancelIgnoringExceptions(); } }
/** * Removes and cancels all tasks in queue. Can be called from any * thread. */ final void cancelTasks() { ForkJoinTask<?> cj = currentJoin; // try to cancel ongoing tasks if (cj != null && cj.status >= 0) cj.cancelIgnoringExceptions(); ForkJoinTask<?> cs = currentSteal; if (cs != null && cs.status >= 0) cs.cancelIgnoringExceptions(); while (queueBase != queueTop) { ForkJoinTask<?> t = deqTask(); if (t != null) t.cancelIgnoringExceptions(); } }
p.addActiveCount(1); if ((t = (v != this) ? v.deqTask() : locallyFifo ? locallyDeqTask() : popTask()) != null) { currentSteal = t;
p.addActiveCount(1); if ((t = (v != this) ? v.deqTask() : locallyFifo ? locallyDeqTask() : popTask()) != null) { currentSteal = t;
p.addActiveCount(1); if ((t = (v != this) ? v.deqTask() : locallyFifo ? locallyDeqTask() : popTask()) != null) { currentSteal = t;