ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166y/ForkJoinPool.java
(Generate patch)

Comparing jsr166/src/jsr166y/ForkJoinPool.java (file contents):
Revision 1.22 by jsr166, Sat Jul 25 00:34:00 2009 UTC vs.
Revision 1.26 by jsr166, Sun Jul 26 13:34:25 2009 UTC

# Line 548 | Line 548 | public class ForkJoinPool extends Abstra
548       * Common code for execute, invoke and submit
549       */
550      private <T> void doSubmit(ForkJoinTask<T> task) {
551 +        if (task == null)
552 +            throw new NullPointerException();
553          if (isShutdown())
554              throw new RejectedExecutionException();
555          if (workers == null)
# Line 583 | Line 585 | public class ForkJoinPool extends Abstra
585      // AbstractExecutorService methods
586  
587      public void execute(Runnable task) {
588 <        doSubmit(new AdaptedRunnable<Void>(task, null));
588 >        ForkJoinTask<?> job;
589 >        if (task instanceof ForkJoinTask<?>) // avoid re-wrap
590 >            job = (ForkJoinTask<?>) task;
591 >        else
592 >            job = new AdaptedRunnable<Void>(task, null);
593 >        doSubmit(job);
594      }
595  
596      public <T> ForkJoinTask<T> submit(Callable<T> task) {
# Line 599 | Line 606 | public class ForkJoinPool extends Abstra
606      }
607  
608      public ForkJoinTask<?> submit(Runnable task) {
609 <        ForkJoinTask<Void> job = new AdaptedRunnable<Void>(task, null);
609 >        ForkJoinTask<?> job;
610 >        if (task instanceof ForkJoinTask<?>) // avoid re-wrap
611 >            job = (ForkJoinTask<?>) task;
612 >        else
613 >            job = new AdaptedRunnable<Void>(task, null);
614          doSubmit(job);
615          return job;
616      }
617  
618      /**
619 +     * Submits a ForkJoinTask for execution.
620 +     *
621 +     * @param task the task to submit
622 +     * @return the task
623 +     * @throws RejectedExecutionException if the task cannot be
624 +     *         scheduled for execution
625 +     * @throws NullPointerException if the task is null
626 +     */
627 +    public <T> ForkJoinTask<T> submit(ForkJoinTask<T> task) {
628 +        doSubmit(task);
629 +        return task;
630 +    }
631 +
632 +    /**
633       * Adaptor for Runnables. This implements RunnableFuture
634       * to be compliant with AbstractExecutorService constraints.
635       */
# Line 1890 | Line 1915 | public class ForkJoinPool extends Abstra
1915      }
1916  
1917      private static final sun.misc.Unsafe UNSAFE = getUnsafe();
1918 <    static final long eventCountOffset =
1918 >    private static final long eventCountOffset =
1919          fieldOffset("eventCount", ForkJoinPool.class);
1920 <    static final long workerCountsOffset =
1920 >    private static final long workerCountsOffset =
1921          fieldOffset("workerCounts", ForkJoinPool.class);
1922 <    static final long runControlOffset =
1922 >    private static final long runControlOffset =
1923          fieldOffset("runControl", ForkJoinPool.class);
1924 <    static final long syncStackOffset =
1924 >    private static final long syncStackOffset =
1925          fieldOffset("syncStack",ForkJoinPool.class);
1926 <    static final long spareStackOffset =
1926 >    private static final long spareStackOffset =
1927          fieldOffset("spareStack", ForkJoinPool.class);
1928  
1929      private boolean casEventCount(long cmp, long val) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines