< prev index next >

jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java

Print this page




1284      * otherwise.
1285      *
1286      * @return a task, or {@code null} if none are available
1287      */
1288     protected static ForkJoinTask<?> pollTask() {
1289         Thread t; ForkJoinWorkerThread wt;
1290         return ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) ?
1291             (wt = (ForkJoinWorkerThread)t).pool.nextTaskFor(wt.workQueue) :
1292             null;
1293     }
1294 
1295     /**
1296      * If the current thread is operating in a ForkJoinPool,
1297      * unschedules and returns, without executing, a task externally
1298      * submitted to the pool, if one is available. Availability may be
1299      * transient, so a {@code null} result does not necessarily imply
1300      * quiescence of the pool.  This method is designed primarily to
1301      * support extensions, and is unlikely to be useful otherwise.
1302      *
1303      * @return a task, or {@code null} if none are available
1304      * @since 1.9
1305      */
1306     protected static ForkJoinTask<?> pollSubmission() {
1307         Thread t;
1308         return ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) ?
1309             ((ForkJoinWorkerThread)t).pool.pollSubmission() : null;
1310     }
1311 
1312     // tag operations
1313 
1314     /**
1315      * Returns the tag for this task.
1316      *
1317      * @return the tag for this task
1318      * @since 1.8
1319      */
1320     public final short getForkJoinTaskTag() {
1321         return (short)status;
1322     }
1323 
1324     /**




1284      * otherwise.
1285      *
1286      * @return a task, or {@code null} if none are available
1287      */
1288     protected static ForkJoinTask<?> pollTask() {
1289         Thread t; ForkJoinWorkerThread wt;
1290         return ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) ?
1291             (wt = (ForkJoinWorkerThread)t).pool.nextTaskFor(wt.workQueue) :
1292             null;
1293     }
1294 
1295     /**
1296      * If the current thread is operating in a ForkJoinPool,
1297      * unschedules and returns, without executing, a task externally
1298      * submitted to the pool, if one is available. Availability may be
1299      * transient, so a {@code null} result does not necessarily imply
1300      * quiescence of the pool.  This method is designed primarily to
1301      * support extensions, and is unlikely to be useful otherwise.
1302      *
1303      * @return a task, or {@code null} if none are available
1304      * @since 9
1305      */
1306     protected static ForkJoinTask<?> pollSubmission() {
1307         Thread t;
1308         return ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) ?
1309             ((ForkJoinWorkerThread)t).pool.pollSubmission() : null;
1310     }
1311 
1312     // tag operations
1313 
1314     /**
1315      * Returns the tag for this task.
1316      *
1317      * @return the tag for this task
1318      * @since 1.8
1319      */
1320     public final short getForkJoinTaskTag() {
1321         return (short)status;
1322     }
1323 
1324     /**


< prev index next >