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

Comparing jsr166/src/jsr166y/ForkJoinTask.java (file contents):
Revision 1.53 by dl, Wed Aug 11 18:45:12 2010 UTC vs.
Revision 1.55 by dl, Sun Aug 29 23:34:46 2010 UTC

# Line 214 | Line 214 | public abstract class ForkJoinTask<V> im
214      }
215  
216      /**
217 <     * Blocks a worker thread until completion. Called only by pool.
217 >     * Blocks a worker thread until completion. Called only by
218 >     * pool. Currently unused -- pool-based waits use timeout
219 >     * version below.
220       */
221      final void internalAwaitDone() {
222          int s;         // the odd construction reduces lock bias effects
# Line 231 | Line 233 | public abstract class ForkJoinTask<V> im
233      }
234  
235      /**
236 +     * Blocks a worker thread until completed or timed out.  Called
237 +     * only by pool.
238 +     *
239 +     * @return status on exit
240 +     */
241 +    final int internalAwaitDone(long millis) {
242 +        int s;
243 +        if ((s = status) >= 0) {
244 +            try {
245 +                synchronized(this) {
246 +                    if (UNSAFE.compareAndSwapInt(this, statusOffset, s,SIGNAL))
247 +                        wait(millis, 0);
248 +                }
249 +            } catch (InterruptedException ie) {
250 +                cancelIfTerminating();
251 +            }
252 +            s = status;
253 +        }
254 +        return s;
255 +    }
256 +
257 +    /**
258       * Blocks a non-worker-thread until completion.
259       */
260      private void externalAwaitDone() {
# Line 643 | Line 667 | public abstract class ForkJoinTask<V> im
667           */
668          boolean interrupted = false;
669          boolean dec = false; // true if pool count decremented
670 +        long nanos = unit.toNanos(timeout);
671          for (;;) {
672              if (Thread.interrupted() && pool == null) {
673                  interrupted = true;
# Line 653 | Line 678 | public abstract class ForkJoinTask<V> im
678                  break;
679              if (UNSAFE.compareAndSwapInt(this, statusOffset, s, SIGNAL)) {
680                  long startTime = System.nanoTime();
656                long nanos = unit.toNanos(timeout);
681                  long nt; // wait time
682                  while (status >= 0 &&
683                         (nt = nanos - (System.nanoTime() - startTime)) > 0) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines